Пример #1
0
        public async Task DeleteFaculty()
        {
            // Arrange
            var user       = UserRegisterModelFactory.getUserFactory("Admin").getUser();
            var university = InstitutionsModelFactory.University();
            var faculty    = InstitutionsModelFactory.Faculty();

            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.DeleteAsync($"api/universities/{university.Id}/faculties/{faculty.Id}");

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

            faculties.Should().BeNull();
        }
Пример #2
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");
        }
Пример #3
0
        public async Task GetRedeemedCoupon()
        {
            // Arrange
            var offerer = UserRegisterModelFactory.getUserFactory("Offerer").getUser();
            var coupon  = CouponModelFactory.Default();

            offerer.AddCoupon(coupon);
            var student    = new Student(this.AuthenticatedUserId);
            var admin      = UserRegisterModelFactory.getUserFactory("Admin").getUser();
            var university = InstitutionsModelFactory.University();
            var faculty    = InstitutionsModelFactory.Faculty();

            university.AddFaculty(faculty);
            faculty.AddStudent(student);

            var redeemedcoupon = new RedeemedCoupon("Used", coupon.Id);

            student.AddRedeemedCoupon(redeemedcoupon);
            await ExecuteDatabaseAction(async couponelContext =>
            {
                await couponelContext.Users.AddAsync(admin);
                await couponelContext.Users.AddAsync(offerer);
                await couponelContext.Universities.AddAsync(university);
                await couponelContext.SaveChangesAsync();
            });

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

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

            redeemedcoupons.Should().NotBeNull();
        }
Пример #4
0
        public async Task GetStudentUser()
        {
            // Arrange
            var admin      = UserRegisterModelFactory.getUserFactory("admin").getUser();
            var user       = UserRegisterModelFactory.getUserFactory("Student").getUser();
            var student    = new Student(user.Id);
            var university = InstitutionsModelFactory.University();
            var faculty    = InstitutionsModelFactory.Faculty();

            university.AddFaculty(faculty);
            faculty.AddStudent(student);
            await ExecuteDatabaseAction(async couponelContext =>
            {
                await couponelContext.Users.AddAsync(admin);
                await couponelContext.Users.AddAsync(user);
                await couponelContext.Universities.AddAsync(university);
                await couponelContext.SaveChangesAsync();
            });

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

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

            users.Should().NotBeNull();
        }
Пример #5
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");
        }