<commit_before>﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NMF.Models.Repository;
using NMF.Models.Tests.Railway;

namespace NMF.Models.Tests
{
    [TestClass]
    public class TransactionTests
    {
        private const string BaseUri = "http://github.com/NMFCode/NMF/Models/Models.Test/railway.railway";

        [TestMethod]
        public void RollbackTest()
        {
            var model = LoadRailwayModel(new ModelRepository());
            var referenceModel = LoadRailwayModel(new ModelRepository());

            using (var trans = new NMFTransaction(model))
            {
                var route = new Route() { Id = 42 };
                model.Routes.Add(route);
                model.Semaphores[0].Signal = Signal.FAILURE;
                model.Routes[0].DefinedBy.RemoveAt(0); //hier aufpassen
                model.Routes[0].DefinedBy[0].Elements.RemoveAt(0);

            }

            Assert.AreEqual(model.Routes.Count, referenceModel.Routes.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy.Count, referenceModel.Routes[0].DefinedBy.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy[0].Elements.Count, referenceModel.Routes[0].DefinedBy[0].Elements.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy[0].Elements[0].ConnectsTo.Count, referenceModel.Routes[0].DefinedBy[0].Elements[0].ConnectsTo.Count);
            Assert.AreEqual(model.Semaphores[0].Signal, referenceModel.Semaphores[0].Signal);
        }

        [TestMethod]
        public void DemoTestCase()
        {
            var model = LoadRailwayModel(new ModelRepository());
            var referenceModel = LoadRailwayModel(new ModelRepository());

            using (var trans = new NMFTransaction(model))
            {
                model.Routes[0].DefinedBy.RemoveAt(0); 
            }

            var debug = model.Routes[0].DefinedBy[0].Elements;
            var debugReference = referenceModel.Routes[0].DefinedBy[0].Elements;
            Assert.AreEqual(debug.First().ConnectsTo.Count, debugReference.First().ConnectsTo.Count);
        }

        [TestMethod]
        public void CommitTest()
        {
            var model = LoadRailwayModel(new ModelRepository());
            var referenceModel = LoadRailwayModel(new ModelRepository());

            using (var trans = new NMFTransaction(model))
            {<commit_msg>Removed debug test case.<commit_after>﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NMF.Models.Repository;
using NMF.Models.Tests.Railway;

namespace NMF.Models.Tests
{
    [TestClass]
    public class TransactionTests
    {
        private const string BaseUri = "http://github.com/NMFCode/NMF/Models/Models.Test/railway.railway";

        [TestMethod]
        public void RollbackTest()
        {
            var model = LoadRailwayModel(new ModelRepository());
            var referenceModel = LoadRailwayModel(new ModelRepository());

            using (var trans = new NMFTransaction(model))
            {
                var route = new Route() { Id = 42 };
                model.Routes.Add(route);
                model.Semaphores[0].Signal = Signal.FAILURE;
                model.Routes[0].DefinedBy.RemoveAt(0); //hier aufpassen
                model.Routes[0].DefinedBy[0].Elements.RemoveAt(0);

            }

            Assert.AreEqual(model.Routes.Count, referenceModel.Routes.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy.Count, referenceModel.Routes[0].DefinedBy.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy[0].Elements.Count, referenceModel.Routes[0].DefinedBy[0].Elements.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy[0].Elements[0].ConnectsTo.Count, referenceModel.Routes[0].DefinedBy[0].Elements[0].ConnectsTo.Count);
            Assert.AreEqual(model.Semaphores[0].Signal, referenceModel.Semaphores[0].Signal);
        }
        

        [TestMethod]
        public void CommitTest()
        {
            var model = LoadRailwayModel(new ModelRepository());
            var referenceModel = LoadRailwayModel(new ModelRepository());

            using (var trans = new NMFTransaction(model))
            {
{'fraction_non_alphanumeric': 0.11554428044280443, 'fraction_numerical': 0.011531365313653136, 'mean_word_length': 2.5346373268133657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7543470', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1213, 'n_words': 193}