public void CreateOrganisationControllerActionCallsTheOrganisationsUseCase() { var requestParams = Randomm.Create <OrganisationRequest>(); _classUnderTest.CreateOrganisation(requestParams); _mockUseCase.Verify(uc => uc.ExecuteCreate(It.IsAny <string>(), It.Is <OrganisationRequest>(p => p == requestParams)), Times.Once); }
public async Task TestCreateOrganisationValidInput() { //Arrange var organisationDto = new OrganisationDto { Name = "Test1", Address = "55 Symonds", Description = "UoA Accomodation", Status = OrganisationStatus.Active, Classifications = new List <string> { "Classficiation", "Classification1" } }; _mockOrganisationRepository.Setup(x => x.InsertAsync(It.IsAny <Organisation>())).Returns(Task.FromResult(1)); //Act ActionResult <CreatedDto> response = await _organisationsController.CreateOrganisation(organisationDto); //Assert Assert.IsInstanceOf <CreatedResult>(response.Result); CreatedResult createdResult = response.Result as CreatedResult; Assert.AreEqual(201, createdResult.StatusCode); CreatedDto value = createdResult.Value.As <CreatedDto>(); Assert.IsNotNull(value); Assert.AreEqual(0, value.Id); _mockOrganisationRepository.Verify(x => x.InsertAsync(It.IsAny <Organisation>()), Times.Once); }