Exemplo n.º 1
0
        public void InitializeIntegrationTest()
        {
            var servicesToReplace = new List <(Type, object)>();

            var configDict = new Dictionary <string, string>
            {
                { "IdentityConfiguration:JwtSecret", "2346sedrfgsrahyjrtyserASD@" },
                { "IdentityConfiguration:ExpirationInSeconds", "3600" },
                { "WolkConfiguration:UploadsPath", UploadsRootPath }
            };

            BeforeConfigure(configDict);
            var config = new ConfigurationBuilder()
                         .AddInMemoryCollection(configDict)
                         .Build();
            var startup = new Startup(config);

            InitializeDefaultDateTime();
            var wolkDbContext = InMemoryDbContextFactory.Create();

            servicesToReplace.Add((typeof(IWolkDbContext), wolkDbContext));
            servicesToReplace.Add((typeof(IFileService), MockFileService));
            servicesToReplace.Add((typeof(IDateTime), MockDateTime.Object));

            var mockEnvironment = new Mock <IWebHostEnvironment>();

            mockEnvironment
            .Setup(m => m.EnvironmentName)
            .Returns("Production");

            TestServer = new TestServer(new WebHostBuilder()
                                        .ConfigureServices(services => ConfigureServices(startup, services, servicesToReplace))
                                        .Configure(app => Startup.ConfigureStatic(app, mockEnvironment.Object, false, false)));
            HttpClient = TestServer.CreateClient();
        }