public void DeleteTest() { Location v = new Location(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v.Name = "bhVtNC"; context.Set <Location>().Add(v); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString()); Assert.IsInstanceOfType(rv.Model, typeof(LocationVM)); LocationVM vm = rv.Model as LocationVM; v = new Location(); v.ID = vm.Entity.ID; vm.Entity = v; _controller.Delete(v.ID.ToString(), null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { Assert.AreEqual(context.Set <Location>().Count(), 0); } }
public void LocationDelete() { //api / v1 / location /{ location_id}/ department / SubCategory sub = new SubCategory(); _httpResponseMessage = _locationController.Delete(1); var actul = _httpResponseMessage.IsSuccessStatusCode; var expected = false; Assert.AreEqual(expected, actul); Assert.AreEqual(HttpStatusCode.NotFound, _httpResponseMessage.StatusCode); }
public static void Cleanup() { foreach (Location obj in _objectsToCleanup) { LocationController.Delete(_authToken, obj, false).Wait(); } }
public void Delete() { // Arrange LocationController controller = new LocationController(); // Act controller.Delete(5); // Assert }
public void DeleteGet_ValidLocationWithAssociatedDate_CannotDelete() { // Arrange - create the controller LocationController target = new LocationController(mock.Object); // Act - call the action method var result = target.Delete(2) as ViewResult; // Assert - check the result Assert.AreEqual("CannotDelete", result.ViewName); Assert.IsInstanceOf(typeof(ViewResult), result); }
public void DeleteGet_InvalidLocation() { // Arrange - create the controller LocationController target = new LocationController(mock.Object); // Act - call the action method var result = (HttpNotFoundResult)target.Delete(15); Location location = mock.Object.Locations.Where(m => m.LocationID == 15).FirstOrDefault(); // Assert - check the result Assert.IsInstanceOf(typeof(HttpNotFoundResult), result); Assert.IsNull(location); Assert.AreEqual(404, result.StatusCode); }
public async Task LOC99_DeleteLocationTest() { // Arrange // Act await LocationController.Delete(_authToken, _location, false); // Assert Assert.IsTrue(_location.IsDeleted, "Location.IsDeleted evaluated to false"); if (_location.IsDeleted) { _objectsToCleanup.Remove(_location); } }
public void GivenNavigatorShowDeleteView() { INavigationRepository repository = GenerateRepository(); LocationController target = new LocationController(repository); Navigator navigator = GenerateNavigator(); ActionResult actual; actual = target.Delete(navigator); Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(ViewResult)); ViewResult result = actual as ViewResult; Assert.AreEqual("Delete", result.ViewName); TestViewResult(navigator, result); }
public async void Delete_Errors() { LocationControllerMockFacade mock = new LocationControllerMockFacade(); var mockResult = new Mock <ActionResponse>(); mockResult.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.FromResult <ActionResponse>(mockResult.Object)); LocationController controller = new LocationController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Delete(default(int)); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Delete(It.IsAny <int>())); }
public void AddressDelete() { //setup Address a = CreateNewAddress(); a = controller.CreateAddress(a); int preCount = TestHelper.CountTable("addresses"); preCount -= 1; //act bool result = controller.Delete(a.Id); int postCount = TestHelper.CountTable("addresses"); //arrange Assert.AreEqual(preCount, postCount); Assert.AreEqual(true, result); }
public void GivenLocationViewModelDeleteLocation() { INavigationRepository repository = GenerateRepository(); LocationController target = new LocationController(repository); LocationViewModel location = Utilities.ObjectFactory.CreateLocation(GenerateNavigator()); repository.Expect(r => r.DeleteLocation(location)).Return(true); ActionResult actual; actual = target.Delete(location); Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(RedirectToRouteResult)); RedirectToRouteResult result = actual as RedirectToRouteResult; Assert.AreEqual("area_default", result.RouteName); Assert.AreEqual("Details", result.RouteValues["Action"]); Assert.AreEqual(location.RegionName, result.RouteValues["RegionName"]); Assert.AreEqual(location.AreaName, result.RouteValues["AreaName"]); repository.VerifyAllExpectations(); }
public static void Cleanup() { foreach (ConfigurationItem obj in _objectsToCleanup) { Task <bool> deleteTask; if (obj is PurchaseOrder) { deleteTask = PurchaseOrderController.Delete(_authToken, (obj as PurchaseOrder), false); } else if (obj is Location) { deleteTask = LocationController.Delete(_authToken, (obj as Location), false); } else { deleteTask = HardwareAssetController.Delete(_authToken, (obj as HardwareAsset), false); } deleteTask.Wait(); } }
public void LocationController_Delete_RemovesElement() { var newLocation = new Location { Id = Guid.NewGuid(), Latitude = -1, Longitude = -1, Name = string.Format("Location {0}", DateTime.Now.TimeOfDay), UserId = TestUser }; var controller = new LocationController(_service, null); controller.Post(newLocation); var location = controller.Get(newLocation.Id); Assert.AreEqual(location.Name, newLocation.Name); controller.Delete(newLocation.Id); location = controller.Get(newLocation.Id); Assert.AreEqual(null, location); }
public void Store2() { // ARRANGE var handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict); handlerMock .Protected() // Setup the PROTECTED method to mock .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ) // prepare the expected response of the mocked http call .ReturnsAsync(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = null, }) .Verifiable(); var httpClient = new HttpClient(handlerMock.Object) { BaseAddress = new Uri("http://test.com/"), }; var subjectUnderTest = new EquipmentController(httpClient, new Web.MyConfiguration() { ServiceUrl = "http://test.com/" }); var result = subjectUnderTest.Index(); var result2 = subjectUnderTest.Create(); var result3 = subjectUnderTest.Create(new EquipmentModel()); var result4 = subjectUnderTest.Edit(new EquipmentModel()); var result5 = subjectUnderTest.Edit(1, 2, "", "", 2, 3, 3); var subjectUnderTest2 = new LocationController(httpClient, new Web.MyConfiguration() { ServiceUrl = "http://test.com/" }); var result6 = subjectUnderTest2.Index(); var result7 = subjectUnderTest2.Create(); var result8 = subjectUnderTest2.Create(new LocationModel()); var result9 = subjectUnderTest2.EditLoot(1, 1, 1, "", 1, ""); var result10 = subjectUnderTest2.EditLoot(new LootModel()); var result11 = subjectUnderTest2.EditLocation(new LocationModel()); var result12 = subjectUnderTest2.EditLocation(1, "", "", 1); var result13 = subjectUnderTest2.Delete(1); var subjectUnderTest3 = new HomeController(); subjectUnderTest3.Index(); subjectUnderTest3.Privacy(); var subjectUnderTest4 = new LootController(httpClient, new Web.MyConfiguration() { ServiceUrl = "http://test.com/" }); var result17 = subjectUnderTest4.Index(); var subjectUnderTest5 = new PlayerController(httpClient, new Web.MyConfiguration() { ServiceUrl = "http://test.com/" }); var result18 = subjectUnderTest5.Index(); var result19 = subjectUnderTest5.Edit(1, 2, "", "", 1, 1); var result20 = subjectUnderTest5.Edit(new LootModel()); var result21 = subjectUnderTest5.EditPlayer(1, "", 1); var result22 = subjectUnderTest5.EditPlayer(new PlayerModel()); var result23 = subjectUnderTest5.EditEquipment(1, 1, "", "", 1, 1, 1); var result24 = subjectUnderTest5.EditEquipment(new EquipmentModel()); var result25 = subjectUnderTest5.Delete(1, new LootModel()); var result26 = subjectUnderTest5.Delete(1); var result27 = subjectUnderTest5.DeleteEquipment(1, new EquipmentModel()); Assert.NotNull(subjectUnderTest); }
public bool deleteAddress(int id) { return(locationController.Delete(id)); }
public async Task Delete_Success(params int[] args) { var res = await controller.Delete(args) as JsonResult; res.Value.Should().Be("Success!"); }