Ejemplo n.º 1
0
        public async Task Index_Get_ReturnsListOfApplications()
        {
            // Arrange
            using (var app = new TestApplication())
            {
                // Get predefined data
                var data = GetPredefinedData();
                // Get seeder
                var seeder = app.GetSeeder();
                // Write data to db
                await seeder.SeedAsync(data);

                var client = app.GetClient();

                // Act
                var response = await client.GetAsync("/");

                response.EnsureSuccessStatusCode();

                var responseString = await response.Content.ReadAsStringAsync();

                // Assert
                foreach (var application in data.Applications)
                {
                    Assert.Contains($"<h5 class=\"card-title\">{application.Name}</h5>", responseString);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task CheckDataBaseStates()
        {
            // Arrange
            using (var app = new TestApplication())
            {
                Guid failedId = Guid.NewGuid();
                // Get predefined data
                var data = GetPredefinedData(failedId);
                // Get seeder
                var seeder = app.GetSeeder();
                // Write data to db
                await seeder.SeedAsync(data);

                // Act
                // TODO: don't know how to get the total check time
                Thread.Sleep(30000);

                var dbContext = app.GetContext();

                // Assert
                foreach (var application in data.Applications)
                {
                    var checkHistoryRecord =
                        await dbContext.History.FirstOrDefaultAsync(x => x.ApplicationId == application.Id);

                    Assert.NotNull(checkHistoryRecord);
                    Assert.NotEqual(ApplicationState.DidNotCheck, checkHistoryRecord.State);

                    if (checkHistoryRecord.ApplicationId != failedId)
                    {
                        Assert.Equal(ApplicationState.Available, checkHistoryRecord.State);
                    }
                    else
                    {
                        Assert.Equal(ApplicationState.CheckedWithError, checkHistoryRecord.State);
                    }
                }
            }
        }