コード例 #1
0
        public async Task UpdateFaculty()
        {
            // Arrange
            var user       = UserRegisterModelFactory.getUserFactory("Admin").getUser();
            var university = InstitutionsModelFactory.University();
            var faculty    = InstitutionsModelFactory.Faculty();

            faculty.Update("faculty", "*****@*****.**", "0745624578", InstitutionsModelFactory.Address());
            university.AddFaculty(faculty);
            await ExecuteDatabaseAction(async couponelContext =>
            {
                await couponelContext.Users.AddAsync(user);
                await couponelContext.Universities.AddAsync(university);
                await couponelContext.SaveChangesAsync();
            });

            //Act
            var response = await HttpClient.GetAsync($"api/universities/{university.Id}/faculties/{faculty.Id}");

            // Assert
            response.IsSuccessStatusCode.Should().BeTrue();
            var faculties = await response.Content.ReadAsAsync <FacultyModel>();

            faculties.Should().NotBeNull();
            faculties.Name.Should().BeEquivalentTo("faculty");
        }
コード例 #2
0
        public async Task UpdateUniversity()
        {
            // Arrange
            var user       = UserRegisterModelFactory.getUserFactory("Admin").getUser();
            var university = InstitutionsModelFactory.University();

            university.Update("university", "*****@*****.**", "0456324862", InstitutionsModelFactory.Address());
            await ExecuteDatabaseAction(async couponelContext =>
            {
                await couponelContext.Users.AddAsync(user);
                await couponelContext.Universities.AddAsync(university);
                await couponelContext.SaveChangesAsync();
            });

            //Act
            var response = await HttpClient.GetAsync($"api/universities/{university.Id}");

            // Assert
            response.IsSuccessStatusCode.Should().BeTrue();
            var universities = await response.Content.ReadAsAsync <UniversityModel>();

            universities.Address.Street.Should().Be("Bucuriei");
        }