public async Task Add_PartnerOrganization_PartnerOrganizationViewModel_ViewResultDifferentRegistrationCodes() { // Arrange List <PartnerOrganization> partners = new List <PartnerOrganization>(); IRepository <PartnerOrganization> repository = Substitute.For <IRepository <PartnerOrganization> >(); repository.Add(Arg.Any <PartnerOrganization>()).Returns(x => { partners.Add(x.Arg <PartnerOrganization>()); return(Task.CompletedTask); }); PartnerOrganizationController controller = new PartnerOrganizationController(repository); PartnerOrganizationViewModel viewModel = new PartnerOrganizationViewModel(); // Act await controller.AddPartner(viewModel); await controller.AddPartner(viewModel); // Assert Assert.Equal(2, partners.Count); Assert.NotEqual(partners[0].RegistrationCode, partners[1].RegistrationCode); }
public async Task AddPartnerOrganization_PartnerOrganizationViewModelInValid_ReturnsBadRequest() { // Arrange IRepository <PartnerOrganization> repository = Substitute.For <IRepository <PartnerOrganization> >(); PartnerOrganizationController controller = new PartnerOrganizationController(repository); controller.ModelState.AddModelError("Name", "Required"); PartnerOrganizationViewModel viewModel = new PartnerOrganizationViewModel(); // Act IActionResult result = await controller.AddPartner(viewModel); // Assert Assert.IsType <BadRequestObjectResult>(result); }