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"); }
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); }