예제 #1
0
        public void DeleteScenario_ShouldDeleteSameScenario()
        {
            var context = new TestLstmLgBackendContext();

            context.Scenarios.Add(new Scenario {
                id = 1, name = "nba"
            });

            var controller = new ScenariosController(context);

            controller.DeleteScenario("nba");

            var Scenario = context.Scenarios.FirstOrDefault();

            Assert.IsNull(Scenario);

            context.Scenarios.Add(new Scenario {
                id = 2, name = "cba"
            });
            context.Scenarios.Add(new Scenario {
                id = 3, name = "fba"
            });
            controller.DeleteScenario("cba");

            var Scenarios = context.Scenarios;

            Assert.AreEqual(Scenarios.Count(), 1);
            Assert.AreEqual(Scenarios.First().name, "fba");
        }
예제 #2
0
        public void CreateScenario_ShouldAddSameScenario()
        {
            var context = new TestLstmLgBackendContext();

            var controller = new ScenariosController(context);


            //var result1 = controller.CreateScenario("nba");

            //var result2 = controller.CreateScenario("nba");



            //var Scenario = context.Scenarios;

            //Assert.AreEqual(Scenario.Count(), 1);
        }
예제 #3
0
        public void GetScenarios_ShouldReturnAllScenarios()
        {
            var context = new TestLstmLgBackendContext();

            context.Scenarios.Add(new Scenario {
                id = 1, name = "nba"
            });
            context.Scenarios.Add(new Scenario {
                id = 2, name = "stock"
            });

            var controller = new ScenariosController(context);

            var result = controller.GetScenarios() as TestScenarioDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Local.Count);
        }
예제 #4
0
        Given_a_legacy_scenario_with_a_null_DateCreated_when_getting_all_scenarios_then_the_DateCreated_is_null()
        {
            // Arrange
            Fixture fixture = new SafeFixture();

            var fakeRunRepository             = new Mock <IRunRepository>();
            var fakeScenarioRepository        = new Mock <IScenarioRepository>();
            var fakePassRepository            = new Mock <IPassRepository>();
            var fakeTenantSettingsRepository  = new Mock <ITenantSettingsRepository>();
            var fakeIdentityGeneratorResolver = new Mock <IIdentityGeneratorResolver>();
            var fakePassInspectorService      = new Mock <IPassInspectorService>();

            IMapper mapper = AutoMapperInitializer.Initialize(Configuration.AutoMapperConfig.SetupAutoMapper);

            IEnumerable <Pass>          fakePasses         = fixture.CreateMany <Pass>(1);
            IEnumerable <PassReference> fakePassReferences = fixture
                                                             .Build <PassReference>()
                                                             .With(p => p.Id, fakePasses.First().Id)
                                                             .CreateMany(1);

            IEnumerable <Scenario> scenarioWithDateModifiedNull = fixture
                                                                  .Build <Scenario>()
                                                                  .Without(p => p.DateCreated)
                                                                  .With(p => p.Passes, fakePassReferences.ToList())
                                                                  .CreateMany(1);

            TenantSettings fakeTenantSettings = fixture
                                                .Build <TenantSettings>()
                                                .With(p => p.DefaultScenarioId, Guid.NewGuid())
                                                .Create();

            _ = fakePassRepository
                .Setup(m => m.FindByIds(It.IsAny <IEnumerable <int> >()))
                .Returns(fakePasses);

            _ = fakeScenarioRepository
                .Setup(m => m.GetAll())
                .Returns(scenarioWithDateModifiedNull);

            _ = fakeTenantSettingsRepository
                .Setup(m => m.Get())
                .Returns(fakeTenantSettings);

            using (var scenariosController = new ScenariosController(
                       fakeRunRepository.Object,
                       fakeScenarioRepository.Object,
                       fakePassRepository.Object,
                       fakeTenantSettingsRepository.Object,
                       fakeIdentityGeneratorResolver.Object,
                       mapper,
                       null,
                       null,
                       fakePassInspectorService.Object
                       ))
            {
                // Act
                IEnumerable <ScenarioModel> result = scenariosController.GetAll();

                // Assert
                Assert.That(result.First().DateCreated, Is.Null);
            }
        }