Example #1
0
        public Host CreateHost()
        {
            Type type = typeof(HostFactory);

            HostLogger.Get <HostConfiguratorImpl>()
            .InfoFormat("{0} v{1}, .NET Framework v{2}", type.Namespace, type.Assembly.GetName().Version,
                        Environment.Version);

            EnvironmentBuilder environmentBuilder = _environmentBuilderFactory(this);

            HostEnvironment environment = environmentBuilder.Build();

            ServiceBuilder serviceBuilder = _serviceBuilderFactory(_settings);

            HostBuilder builder = _hostBuilderFactory(environment, _settings);

            foreach (HostBuilderConfigurator configurator in _configurators)
            {
                builder = configurator.Configure(builder);
            }

            try
            {
                return(builder.Build(serviceBuilder));
            }
            //Intercept exceptions from serviceBuilder, TopShelf handling is in HostFactory
            catch (Exception ex)
            {
                builder.Settings?.ExceptionCallback(ex);
                throw;
            }
        }
        public void RollbackDataTest()
        {
            var lookupCode = new LookupCode
            {
                Description = "desc"
            };

            using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions()))
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (TransactionScope scope2 = new TransactionScope())
                    {
                        dbContext.LookupCode.Add(lookupCode);
                        dbContext.SaveChanges();
                        scope2.Complete();
                    }
                    //No scope complete, should rollback.
                }
            }

            using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions()))
            {
                var workSectionCode2 = dbContext.LookupCode.Find(lookupCode.Id);
                Assert.Null(workSectionCode2);
            }
        }
        public void PersistingDataTest()
        {
            var lookupCode = new LookupCode
            {
                Description = "desc"
            };

            using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions()))
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (TransactionScope scope2 = new TransactionScope())
                    {
                        dbContext.LookupCode.Add(lookupCode);
                        dbContext.SaveChanges();
                        scope2.Complete();
                        scope.Complete();
                    }
                }
            }

            using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions()))
            {
                var workSectionCode2 = dbContext.LookupCode.Find(lookupCode.Id);
                Assert.NotNull(workSectionCode2);
                dbContext.Remove(workSectionCode2);
                dbContext.SaveChanges();
            }
        }
Example #4
0
    private void GenerateBuiltinTypes()
    {
        Debug.Assert(Environment is not null);
        Debug.Assert(EnvironmentBuilder is not null);

        var globalTypesList = EnvironmentBuilder.GetOrCreateNamespace(Environment.GlobalTypesNamespace).NamespaceData.Types;

        globalTypesList.Add(GenerateBuiltinTypes_Int(ES_IntSize.Int8, false));
        globalTypesList.Add(GenerateBuiltinTypes_Int(ES_IntSize.Int16, false));
        globalTypesList.Add(GenerateBuiltinTypes_Int(ES_IntSize.Int32, false));
        globalTypesList.Add(GenerateBuiltinTypes_Int(ES_IntSize.Int64, false));

        globalTypesList.Add(GenerateBuiltinTypes_Int(ES_IntSize.Int8, true));
        globalTypesList.Add(GenerateBuiltinTypes_Int(ES_IntSize.Int16, true));
        globalTypesList.Add(GenerateBuiltinTypes_Int(ES_IntSize.Int32, true));
        globalTypesList.Add(GenerateBuiltinTypes_Int(ES_IntSize.Int64, true));

        var floatType  = GenerateBuiltinTypes_Float(ES_FloatSize.Single);
        var doubleType = GenerateBuiltinTypes_Float(ES_FloatSize.Double);

        EnvironmentBuilder.TypeFloat32 = floatType;
        EnvironmentBuilder.TypeFloat64 = doubleType;
        globalTypesList.Add(floatType);
        globalTypesList.Add(doubleType);

        var voidType = GenerateBuiltinTypes_Simple(ES_PrimitiveTypes.Void, ES_TypeTag.Void, 0);
        var boolType = GenerateBuiltinTypes_Simple(ES_PrimitiveTypes.Bool, ES_TypeTag.Bool, 1);

        EnvironmentBuilder.TypeVoid = voidType;
        EnvironmentBuilder.TypeBool = boolType;
        globalTypesList.Add(voidType);
        globalTypesList.Add(boolType);
    }
        public CourtListControllerTests()
        {
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupCodeServicesClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);
            var lookupService         = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService       = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());

            var claims = new[] {
                new Claim(CustomClaimTypes.JcParticipantId, fileServices.Configuration.GetNonEmptyValue("Request:PartId")),
                new Claim(CustomClaimTypes.JcAgencyCode, fileServices.Configuration.GetNonEmptyValue("Request:AgencyIdentifierId")),
            };
            var identity  = new ClaimsIdentity(claims, "Cookies");
            var principal = new ClaimsPrincipal(identity);

            var courtListService = new CourtListService(fileServices.Configuration, fileServices.LogFactory.CreateLogger <CourtListService>(), fileServicesClient, new Mapper(), lookupService, locationService, new CachingService(), principal);

            _controller = new CourtListController(courtListService)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext(fileServices.Configuration)
            };
        }
        public FilesControllerTests()
        {
            //TODO NInject or some other resolvers.
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupCodeServicesClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);

            _fileServicesClient = fileServicesClient;
            var lookupService   = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());

            _agencyIdentifierId = fileServices.Configuration.GetNonEmptyValue("Request:AgencyIdentifierId");
            _partId             = fileServices.Configuration.GetNonEmptyValue("Request:PartId");
            var claims = new[] {
                new Claim(CustomClaimTypes.JcParticipantId, _partId),
                new Claim(CustomClaimTypes.JcAgencyCode, _agencyIdentifierId),
            };
            var identity  = new ClaimsIdentity(claims, "Cookies");
            var principal = new ClaimsPrincipal(identity);

            var filesService = new FilesService(fileServices.Configuration, fileServicesClient, new Mapper(), lookupService, locationService, new CachingService(), principal);

            //TODO fake this.
            var vcCivilFileAccessHandler = new VcCivilFileAccessHandler(new ScvDbContext());

            _controller = new FilesController(fileServices.Configuration, fileServices.LogFactory.CreateLogger <FilesController>(), filesService, vcCivilFileAccessHandler);
            _controller.ControllerContext = HttpResponseTest.SetupMockControllerContext(fileServices.Configuration);
        }
Example #7
0
        private VostokApplicationRunResult BuildEnvironment()
        {
            ChangeStateTo(VostokApplicationState.EnvironmentSetup);

            try
            {
                var environmentFactorySettings = new VostokHostingEnvironmentFactorySettings
                {
                    ConfigureStaticProviders  = settings.ConfigureStaticProviders,
                    BeaconShutdownTimeout     = settings.BeaconShutdownTimeout,
                    BeaconShutdownWaitEnabled = settings.BeaconShutdownWaitEnabled,
                    SendAnnotations           = settings.SendAnnotations
                };

                environment = EnvironmentBuilder.Build(SetupEnvironment, environmentFactorySettings);

                log = environment.Log.ForContext <VostokHost>();

                return(null);
            }
            catch (Exception error)
            {
                return(ReturnResult(VostokApplicationState.CrashedDuringEnvironmentSetup, error));
            }
        }
Example #8
0
 public ManageTypesControllerTests()
 {
     _dbContext  = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions(useMemoryDatabase: true));
     _controller = new ManageTypesController(new ManageTypesService(_dbContext))
     {
         ControllerContext = HttpResponseTest.SetupMockControllerContext()
     };
 }
    bool winMenuOpened = false; // Quick and dirty solution.

    void Awake()
    {
        gameTime           = GameObject.Find("Sun and Moon").GetComponent <DayNightCycle>();
        gameMenu           = GameObject.Find("Canvas").GetComponent <GameMenuController>();
        mapGenerator       = GetComponent <MapGenerator>();
        playerBuilder      = GetComponent <PlayerBuilder>();
        environmentBuilder = GetComponent <EnvironmentBuilder>();
    }
Example #10
0
        public void Get_ReleaseWithStageAndStepFound_ReleaseWithStageAndStepReturned()
        {
            //Arrange
            var request = new GetReleasesHttpRequestMessageBuilder().Build();

            var expectedRelease     = new ReleaseBuilder().Build();
            var expectedEnvironment = new EnvironmentBuilder().Build();
            var expectedStage       = new StageBuilder().ForEnvironment(expectedEnvironment).Build();
            var expectedStep        = new StepBuilder()
                                      .ForRelease(expectedRelease)
                                      .ForStage(expectedStage)
                                      .Build();
            var expectedDeploymentStep = new DeploymentStepBuilder()
                                         .ForRelease(expectedRelease)
                                         .ForStage(expectedStage)
                                         .ForStep(expectedStep)
                                         .Build();

            var dataModel = new DataModelBuilder()
                            .WithRelease(expectedRelease)
                            .WithEnvironment(expectedEnvironment)
                            .WithStage(expectedStage)
                            .WithStageWorkflowFor(expectedRelease, expectedStage)
                            .WithStep(expectedStep)
                            .WithDeploymentStep(expectedDeploymentStep)
                            .Build();

            _releaseRepositoryMock.Setup((stub) => stub.GetReleaseData(It.IsAny <string>(), It.IsAny <int>()))
            .Returns(dataModel);

            //Act
            dynamic result = _sut.Get(request);

            //Assert
            Assert.IsNotNull(result, "Unexpected result");

            Assert.IsInstanceOfType(result.releases, typeof(List <dynamic>), "Unexpected type for releases collection");
            Assert.AreEqual(1, result.releases.Count, "Unexpected number of releases");
            var actualRelease = result.releases[0];

            AssertAreReleasesEqual(expectedRelease, actualRelease);

            Assert.IsInstanceOfType(actualRelease.stages, typeof(List <dynamic>), "Unexpected type for stages collection");
            Assert.AreEqual(1, actualRelease.stages.Count, "Unexpected number of stages for release");
            var actualStage = actualRelease.stages[0];

            AssertAreStagesEqual(expectedStage, expectedEnvironment, actualStage);

            Assert.IsInstanceOfType(actualStage.steps, typeof(List <dynamic>), "Unexpected type for steps collection");
            Assert.AreEqual(1, actualStage.steps.Count, "Unexpected number of steps for stage");
            var actualStep = actualStage.steps[0];

            AssertAreStepsEqual(expectedStep, actualStep);

            Assert.IsInstanceOfType(actualStep.deploymentSteps, typeof(List <dynamic>), "Unexpected type for deploymentStep collection");
            Assert.AreEqual(1, actualStep.deploymentSteps.Count, "Unexpected number of steps for deploymentSteps");
            AssertAreDeploymentStepsEqual(expectedDeploymentStep, actualStep.deploymentSteps[0]);
        }
        public ShiftControllerTests() : base(false)
        {
            var environment = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");

            ShiftController = new ShiftController(new ShiftService(Db, new SheriffService(Db), environment.Configuration), Db)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext()
            };
        }
Example #12
0
    private static void ExpectCommandException(Selections selections)
    {
        var storeMock = new Mock <IImplementationStore>(MockBehavior.Loose);

        storeMock.Setup(x => x.GetPath(It.IsAny <ManifestDigest>())).Returns("test path");
        var executor = new EnvironmentBuilder(storeMock.Object);

        executor.Invoking(x => x.Inject(selections))
        .Should().Throw <ExecutorException>(because: "Invalid Selections should be rejected");
    }
        public EnvironmentBuilder CreateEnvironmentBuilder()
        {
            var layoutEngineOptions = new LayoutEngineOptions(TaskPoolScheduler.Default, Birch.iOS.Reactive.Concurrency.DispatchScheduler.MainThreadScheduler);

            var builder = new EnvironmentBuilder().With <IosHostEnvironment, HostEnvironment>(
                new HostEnvironment(new ShadowMapperFactory(), new XamarinForms.Hosts.DefaultErrorPolicy(), null, new LayoutResolver(),
                                    layoutEngineOptions));

            return(builder);
        }
Example #14
0
        public EnvironmentBuilder CreateEnvironmentBuilder()
        {
            var layoutEngineOptions = new LayoutEngineOptions(Scheduler.Default, Birch.Reactive.Concurrency.HandlerScheduler.MainThreadScheduler);

            var builder = new EnvironmentBuilder().With <AndroidXamFormsHostEnvironmentBuilder, HostEnvironment>(
                new HostEnvironment(new ShadowMapperFactory(), new DefaultErrorPolicy(), null, new LayoutResolver(),
                                    layoutEngineOptions, LayoutHostSettings.Default));

            return(builder);
        }
 // Use this for initialization
 void Start()
 {
     isColliding           = false;
     environmentBuilder    = GameObject.Find("GameManager").GetComponent <EnvironmentBuilder>();
     damageTimer           = 0;
     healthSlider.maxValue = health;
     healthSlider.value    = healthSlider.minValue;
     //healthSlider.enabled = false;
     playerController = GameManager.instance.player.GetComponent <PlayerController>();
     playerManager    = GameManager.instance.player.GetComponent <PlayerManager>();
 }
Example #16
0
        public UserControllerTests() : base(false)
        {
            var environment         = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var httpContextAccessor = new HttpContextAccessor {
                HttpContext = HttpResponseTest.SetupHttpContext()
            };

            _controller = new SheriffController(new SheriffService(Db, httpContextAccessor), new UserService(Db), environment.Configuration, Db)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext()
            };
        }
Example #17
0
        public void Search_RootPath_AllFilesAndDirectoriesFoundAndSave()
        {
            // arrange
            var expectedItemsForSave = EnvironmentBuilder.Create(_numberOfDirectories, _numberOfFiles);
            var listener             = new Listener(_fileSystemVisitor, expectedItemsForSave, expectedItemsForSave);

            //act
            _fileSystemVisitor.Search(_rootPath);
            EnvironmentBuilder.Clear(_rootPath);

            //assert
            Assert.AreEqual(expectedItemsForSave, _fileSystemVisitor.Count);
        }
Example #18
0
        public ShiftControllerTests() : base(false)
        {
            var environment  = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var shiftService = new ShiftService(Db, new SheriffService(Db, environment.Configuration),
                                                environment.Configuration);
            var dutyRosterService = new DutyRosterService(Db, environment.Configuration,
                                                          shiftService, environment.LogFactory.CreateLogger <DutyRosterService>());

            ShiftController = new ShiftController(shiftService, dutyRosterService, Db, environment.Configuration)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext()
            };
        }
        public void SetsPayload()
        {
            var dateTimeMoq = new Mock <IDateTime>();

            dateTimeMoq.Setup(d => d.UtcNow).Returns(new DateTime(2016, 6, 12, 2, 21, 6, DateTimeKind.Utc));
            var environmentBuilder = new EnvironmentBuilder(dateTimeMoq.Object);
            var payload            = new Payload();

            environmentBuilder.Execute(payload);
            Assert.Equal(1465698066L, payload.Data?.Timestamp);
            Assert.Equal("C#", payload.Data?.Language);
            Assert.Equal(".NET Core", payload.Data?.Platform);
        }
Example #20
0
    public void Exceptions()
    {
        var executor = new EnvironmentBuilder(new Mock <IImplementationStore>(MockBehavior.Loose).Object);

        executor.Invoking(x => x.Inject(new Selections {
            Command = Command.NameRun
        }))
        .Should().Throw <ExecutorException>(because: "Selections with no implementations should be rejected");
        executor.Invoking(x => x.Inject(new Selections {
            Implementations = { new ImplementationSelection() }
        }))
        .Should().Throw <ExecutorException>(because: "Selections with no start command should be rejected");
    }
Example #21
0
        public void Search_RootPath_ExcludeFileFromSaving()
        {
            // arrange
            var expectedItemsForSave = EnvironmentBuilder.Create(_numberOfDirectories, _numberOfFiles);
            var listener             = new Listener(_fileSystemVisitor, expectedItemsForSave, _countItemsForExclude);

            //act
            _fileSystemVisitor.Search(_rootPath);
            EnvironmentBuilder.Clear(_rootPath);

            //assert
            Assert.AreEqual(_countItemsForExclude, _fileSystemVisitor.Count);
        }
Example #22
0
        public void Search_RootPath_CancelAfterSaveFirstItem()
        {
            // arrange
            var expectedItemsForSave = EnvironmentBuilder.Create(_numberOfDirectories, _numberOfFiles);
            var listener             = new Listener(_fileSystemVisitor, _countItemsForCancel, expectedItemsForSave);

            //act
            _fileSystemVisitor.Search(_rootPath);
            EnvironmentBuilder.Clear(_rootPath);

            //assert
            Assert.AreEqual(_countItemsForCancel, _fileSystemVisitor.Count);
        }
Example #23
0
    void CreateGameObjects()
    {
        baseObjectList = new List <BaseObject> ();

        Villager tempVillager = Instantiate(villagerGO);

        tempVillager.Init(10, 10f, 50, 10, 10, 100, "Villager", 100, new Vector3(10, 1, 0));
        baseObjectList.Add(tempVillager);

        Villager v1 = Instantiate(villagerGO);

        v1.Init(10, 10f, 50, 10, 10, 100, "Villager", 100, new Vector3(0, 1, 10));
        baseObjectList.Add(v1);

        Villager v2 = Instantiate(villagerGO);

        v2.Init(10, 10f, 50, 10, 10, 100, "Villager", 100, new Vector3(20, 1, 20));
        baseObjectList.Add(v2);

        Villager v3 = Instantiate(villagerGO);

        v3.Init(10, 10f, 50, 10, 10, 100, "Villager", 100, new Vector3(5, 1, 0));
        baseObjectList.Add(v3);

        ResourceNode gNode = Instantiate(goldMine);

        gNode.Init(ResourceType.Gold, "GoldMine", 100, new Vector3(15, 1, 0));
        baseObjectList.Add(gNode);

        ResourceNode iNode = Instantiate(ironMine);

        iNode.Init(ResourceType.Gold, "IronMine", 100, new Vector3(0, 1, 15));
        baseObjectList.Add(iNode);

        ResourceNode sNode = Instantiate(stoneMine);

        sNode.Init(ResourceType.Gold, "StoneMine", 100, new Vector3(7, 1, 7));
        baseObjectList.Add(sNode);


        environmentBuilder = GetComponent <EnvironmentBuilder> ();

//		environmentBuilder.Init (50,50);
//		environmentBuilder.SpawnObjectGreaterThan (treeNode,0.5f);
//		environmentBuilder.SpawnObjectLessThan (goldMine, 0.1f);

        //Create resource nodes ect.
        //Create a town center
        //Create X villagers
        //Set camera to look at town center
    }
Example #24
0
        public void MasterSetup()
        {
            var globalContext      = new GlobalContext();
            var environmentContext = new EnvironmentContext();
            var config             = new ConfigurationBuilder()
                                     .SetBasePath(Directory.GetCurrentDirectory() + "\\Framework\\Config")
                                     .AddJsonFile("appSettings.json", false, true)
                                     .Build();

            environmentContext.BaseAddress   = EnvironmentBuilder.GetConfigValue(config, "environment");
            environmentContext.Path          = EnvironmentBuilder.GetConfigValue(config, "path");
            globalContext.EnvironmentContext = environmentContext;
            GlobalContext = globalContext;
        }
        public FilesControllerTests()
        {
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupServiceClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);
            var lookupService         = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService       = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());
            var filesService          = new FilesService(fileServices.Configuration, fileServicesClient, new Mapper(), lookupService, locationService, new CachingService());

            _controller = new FilesController(fileServices.Configuration, fileServices.LogFactory.CreateLogger <FilesController>(), filesService);
            _controller.ControllerContext = HttpResponseTest.SetupMockControllerContext();
        }
Example #26
0
        public void Get_StageWithMultipleSteps_StepsAreOrderdByAttemptAndThenByRank()
        {
            //Arrange
            var request = new GetReleasesHttpRequestMessageBuilder().Build();

            var expectedRelease     = new ReleaseBuilder().Build();
            var expectedEnvironment = new EnvironmentBuilder().Build();
            var expectedStage       = new StageBuilder().ForEnvironment(expectedEnvironment).Build();

            var expectedStepBuilder = new StepBuilder().ForRelease(expectedRelease).ForStage(expectedStage);
            var expectedStepWithAttempt1AndRank1 = expectedStepBuilder.WithAttempt(1).WithRank(1).Build();
            var expectedStepWithAttempt1AndRank2 = expectedStepBuilder.WithAttempt(1).WithRank(2).Build();
            var expectedStepWithAttempt1AndRank3 = expectedStepBuilder.WithAttempt(1).WithRank(3).Build();
            var expectedStepWithAttempt2AndRank1 = expectedStepBuilder.WithAttempt(2).WithRank(1).Build();
            var expectedStepWithAttempt2AndRank2 = expectedStepBuilder.WithAttempt(2).WithRank(2).Build();

            var dataModel = new DataModelBuilder()
                            .WithRelease(expectedRelease)
                            .WithEnvironment(expectedEnvironment)
                            .WithStage(expectedStage)
                            .WithStageWorkflowFor(expectedRelease, expectedStage)

                            //add steps in 'random' order to check sorting of steps by attempt and then by rank
                            .WithStep(expectedStepWithAttempt2AndRank2)
                            .WithStep(expectedStepWithAttempt1AndRank2)
                            .WithStep(expectedStepWithAttempt1AndRank1)
                            .WithStep(expectedStepWithAttempt1AndRank3)
                            .WithStep(expectedStepWithAttempt2AndRank1)
                            .Build();

            _releaseRepositoryMock.Setup((stub) => stub.GetReleaseData(It.IsAny <string>(), It.IsAny <int>()))
            .Returns(dataModel);

            //Act
            dynamic result = _sut.Get(request);

            //Assert
            Assert.IsNotNull(result, "Unexpected result");

            var stage = result.releases[0].stages[0];

            Assert.AreEqual(expectedStepWithAttempt1AndRank1.Id, stage.steps[0].id, "Unexpected first step");
            Assert.AreEqual(expectedStepWithAttempt1AndRank2.Id, stage.steps[1].id, "Unexpected second step");
            Assert.AreEqual(expectedStepWithAttempt1AndRank3.Id, stage.steps[2].id, "Unexpected third step");
            Assert.AreEqual(expectedStepWithAttempt2AndRank1.Id, stage.steps[3].id, "Unexpected fourth step");
            Assert.AreEqual(expectedStepWithAttempt2AndRank2.Id, stage.steps[4].id, "Unexpected fifth step");
        }
        public CourtListControllerTests()
        {
            var fileServices          = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url");
            var lookupServices        = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url");
            var locationServices      = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url");
            var lookupServiceClient   = new LookupServiceClient(lookupServices.HttpClient);
            var locationServiceClient = new LocationServicesClient(locationServices.HttpClient);
            var fileServicesClient    = new FileServicesClient(fileServices.HttpClient);
            var lookupService         = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService());
            var locationService       = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService());
            var courtListService      = new CourtListService(fileServices.Configuration, fileServicesClient, new Mapper(), lookupService, locationService, new CachingService());

            _controller = new CourtListController(courtListService)
            {
                ControllerContext = HttpResponseTest.SetupMockControllerContext()
            };
        }
Example #28
0
        public async Task SendTestEmail()
        {
            var env = new EnvironmentBuilder(null, null, null);

            var options =
                EnvironmentBuilder.CreateIOptionSnapshotMock(env.Configuration.GetSection(ChesEmailOptions.Position)
                                                             .Get <ChesEmailOptions>());

            var httpClientFactory = new Mock <IHttpClientFactory>();

            httpClientFactory.Setup(_ => _.CreateClient(It.IsAny <string>())).Returns(new HttpClient());

            var chesService = new ChesEmailService(options, httpClientFactory.Object, env.LogFactory.CreateLogger <ChesEmailService>());

            await chesService.SendEmail("Hello", "Test",
                                        env.Configuration.GetNonEmptyValue("TestEmailAddress"));
        }
Example #29
0
        private VostokHostingEnvironment SetupEnvironment()
        {
            var environmentFactorySettings = new VostokHostingEnvironmentFactorySettings
            {
                ConfigureStaticProviders = settings.ConfigureStaticProviders,
                DiagnosticMetricsEnabled = settings.DiagnosticMetricsEnabled
            };

            return(EnvironmentBuilder.Build(
                       builder =>
            {
                builder.SetupApplicationIdentity(
                    identityBuilder => identityBuilder
                    .SetProject("VostokMultiHost")
                    .SetEnvironment("VostokMultiHost")
                    .SetApplication("VostokMultiHost")
                    .SetInstance("VostokMultiHost"));

                settings.EnvironmentSetup(builder);

                builder.SetupLog(logBuilder => logBuilder.CustomizeLog(toCustomize => toCustomize.ForContext <VostokMultiHost>()));

                builder.DisableServiceBeacon();

                builder.SetupLog(logBuilder => logBuilder.SetupHerculesLog(herculesLogBuilder => herculesLogBuilder.Disable()));

                builder.SetupMetrics(metricsBuilder => metricsBuilder.SetupHerculesMetricEventSender(senderBuilder => senderBuilder.Disable()));

                builder.SetupSystemMetrics(
                    systemMetricsSettings =>
                {
                    systemMetricsSettings.EnableGcEventsLogging = false;
                    systemMetricsSettings.EnableGcEventsMetrics = false;
                    systemMetricsSettings.EnableProcessMetricsLogging = false;
                    systemMetricsSettings.EnableProcessMetricsReporting = false;
                    systemMetricsSettings.EnableHostMetricsLogging = false;
                    systemMetricsSettings.EnableHostMetricsReporting = false;
                });
            },
                       environmentFactorySettings
                       ));
        }
Example #30
0
        public async Task Test_HTMLApp_Start_Should_not_Override_Session()
        {
            using (var ctx = new EnvironmentBuilder())
            {
                HTMLApp     target = null;
                IDispatcher disp   = await Task.Run(() =>
                {
                    target = new HTMLApp();
                    return(new WPFUIDispatcher(target.Dispatcher));
                });

                Task.Run(() =>
                {
                    Thread.Sleep(1000);
                    CefCoreSessionSingleton.Session.Should().Be(ctx.Session);
                    disp.Run(() => target.Shutdown(0));
                });

                disp.Run(() => target.Run());
            }
        }
Example #31
0
        public async Task Test_HTMLApp_Start_Should_not_Override_Session()
        {
            using (var ctx = new EnvironmentBuilder())
            {
                HTMLApp target = null;
                IDispatcher disp = await Task.Run(() =>
                {
                    target = new HTMLApp();
                    return new WPFUIDispatcher(target.Dispatcher);

                });

                Task.Run(() =>
                {
                    Thread.Sleep(1000);
                    CefCoreSessionSingleton.Session.Should().Be(ctx.Session);
                    disp.Run(() => target.Shutdown(0));
                });

                disp.Run(() => target.Run());
            }
        }
        public void Get_StageWithMultipleSteps_StepsAreOrderdByAttemptAndThenByRank()
        {
            //Arrange
            var request = new GetReleasesHttpRequestMessageBuilder().Build();

            var expectedRelease = new ReleaseBuilder().Build();
            var expectedEnvironment = new EnvironmentBuilder().Build();
            var expectedStage = new StageBuilder().ForEnvironment(expectedEnvironment).Build();

            var expectedStepBuilder = new StepBuilder().ForRelease(expectedRelease).ForStage(expectedStage);
            var expectedStepWithAttempt1AndRank1 = expectedStepBuilder.WithAttempt(1).WithRank(1).Build();
            var expectedStepWithAttempt1AndRank2 = expectedStepBuilder.WithAttempt(1).WithRank(2).Build();
            var expectedStepWithAttempt1AndRank3 = expectedStepBuilder.WithAttempt(1).WithRank(3).Build();
            var expectedStepWithAttempt2AndRank1 = expectedStepBuilder.WithAttempt(2).WithRank(1).Build();
            var expectedStepWithAttempt2AndRank2 = expectedStepBuilder.WithAttempt(2).WithRank(2).Build();

            var dataModel = new DataModelBuilder()
                .WithRelease(expectedRelease)
                .WithEnvironment(expectedEnvironment)
                .WithStage(expectedStage)
                .WithStageWorkflowFor(expectedRelease, expectedStage)

                //add steps in 'random' order to check sorting of steps by attempt and then by rank
                .WithStep(expectedStepWithAttempt2AndRank2)
                .WithStep(expectedStepWithAttempt1AndRank2)
                .WithStep(expectedStepWithAttempt1AndRank1)
                .WithStep(expectedStepWithAttempt1AndRank3)
                .WithStep(expectedStepWithAttempt2AndRank1)
                .Build();

            _releaseRepositoryMock.Setup((stub) => stub.GetReleaseData(It.IsAny<string>(), It.IsAny<int>()))
                .Returns(dataModel);

            //Act
            dynamic result = _sut.Get(request);

            //Assert
            Assert.IsNotNull(result, "Unexpected result");

            var stage = result.releases[0].stages[0];
            Assert.AreEqual(expectedStepWithAttempt1AndRank1.Id, stage.steps[0].id, "Unexpected first step");
            Assert.AreEqual(expectedStepWithAttempt1AndRank2.Id, stage.steps[1].id, "Unexpected second step");
            Assert.AreEqual(expectedStepWithAttempt1AndRank3.Id, stage.steps[2].id, "Unexpected third step");
            Assert.AreEqual(expectedStepWithAttempt2AndRank1.Id, stage.steps[3].id, "Unexpected fourth step");
            Assert.AreEqual(expectedStepWithAttempt2AndRank2.Id, stage.steps[4].id, "Unexpected fifth step");
        }
        public void Get_ReleaseWithStageAndStepFound_ReleaseWithStageAndStepReturned()
        {
            //Arrange
            var request = new GetReleasesHttpRequestMessageBuilder().Build();

            var expectedRelease = new ReleaseBuilder().Build();
            var expectedEnvironment = new EnvironmentBuilder().Build();
            var expectedStage = new StageBuilder().ForEnvironment(expectedEnvironment).Build();
            var expectedStep = new StepBuilder()
                .ForRelease(expectedRelease)
                .ForStage(expectedStage)
                .Build();
            var expectedDeploymentStep = new DeploymentStepBuilder()
                .ForRelease(expectedRelease)
                .ForStage(expectedStage)
                .ForStep(expectedStep)
                .Build();

            var dataModel = new DataModelBuilder()
                .WithRelease(expectedRelease)
                .WithEnvironment(expectedEnvironment)
                .WithStage(expectedStage)
                .WithStageWorkflowFor(expectedRelease, expectedStage)
                .WithStep(expectedStep)
                .WithDeploymentStep(expectedDeploymentStep)
                .Build();

            _releaseRepositoryMock.Setup((stub) => stub.GetReleaseData(It.IsAny<string>(), It.IsAny<int>()))
                .Returns(dataModel);

            //Act
            dynamic result = _sut.Get(request);

            //Assert
            Assert.IsNotNull(result, "Unexpected result");

            Assert.IsInstanceOfType(result.releases, typeof(List<dynamic>), "Unexpected type for releases collection");
            Assert.AreEqual(1, result.releases.Count, "Unexpected number of releases");
            var actualRelease = result.releases[0];
            AssertAreReleasesEqual(expectedRelease, actualRelease);

            Assert.IsInstanceOfType(actualRelease.stages, typeof(List<dynamic>), "Unexpected type for stages collection");
            Assert.AreEqual(1, actualRelease.stages.Count, "Unexpected number of stages for release");
            var actualStage = actualRelease.stages[0];
            AssertAreStagesEqual(expectedStage, expectedEnvironment, actualStage);

            Assert.IsInstanceOfType(actualStage.steps, typeof(List<dynamic>), "Unexpected type for steps collection");
            Assert.AreEqual(1, actualStage.steps.Count, "Unexpected number of steps for stage");
            var actualStep = actualStage.steps[0];
            AssertAreStepsEqual(expectedStep, actualStep);

            Assert.IsInstanceOfType(actualStep.deploymentSteps, typeof(List<dynamic>), "Unexpected type for deploymentStep collection");
            Assert.AreEqual(1, actualStep.deploymentSteps.Count, "Unexpected number of steps for deploymentSteps");
            AssertAreDeploymentStepsEqual(expectedDeploymentStep, actualStep.deploymentSteps[0]);
        }