示例#1
0
        public async Task AddApartmentSuccessful()
        {
            var context = new POAMDbContext();

            RemoveUser(context);

            var user = CreateUser(context);

            Authentication.Instance.UserLogin(user);

            RemoveApartment(context, "DummyBuilding");

            var apartment = GenerateApartment();

            var apartmentController = new ApartmentController(context);

            var result = await apartmentController.AddApartment(apartment);

            var existingApartment = context.Apartment.FirstOrDefault(a => a.Building == "DummyBuilding");


            Assert.NotNull(existingApartment);
            var redirectResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.NotNull(redirectResult);
            Assert.Equal("MainPage", redirectResult.ActionName);

            Authentication.Instance.Logout();
            RemoveApartment(context, "DummyBuilding");
        }
示例#2
0
        public async Task AddApartmentUserNotLoggedIn()
        {
            var context = new POAMDbContext();

            RemoveApartment(context, "DummyBuilding");

            var apartment = GenerateApartment();

            var apartmentController = new ApartmentController(context);

            var result = await apartmentController.AddApartment(apartment);

            var existingApartment = context.Apartment.FirstOrDefault(a => a.Building == "DummyBuilding");

            Assert.Null(existingApartment);
            var redirectResult = Assert.IsType <RedirectResult>(result);

            Assert.NotNull(redirectResult);
            Assert.Equal("~/Home/Index", redirectResult.Url);
        }