コード例 #1
0
        public void GetOrganisationControllerActionCallsTheOrganisationsUseCase()
        {
            var requestParam = Randomm.Create <int>();

            _classUnderTest.GetOrganisation(requestParam);
            _mockUseCase.Verify(uc => uc.ExecuteGet(It.Is <int>(p => p == requestParam)), Times.Once);
        }
コード例 #2
0
        public async Task TestGetOneOrganisation()
        {
            //Arrange
            var projects = new List <Project> {
                new Project {
                    Id = 1
                }, new Project {
                    Id = 2
                }
            };
            var organisation = new Organisation
            {
                Id              = 1,
                Name            = "Test1",
                Address         = "55 Symonds",
                Description     = "UoA Accomodation",
                Status          = OrganisationStatus.Active,
                Classifications = new List <string> {
                    "Classficiation", "Classification1"
                },
                Projects = projects
            };

            _mockOrganisationRepository.Setup(x => x.GetByIdAsync(1))
            .Returns(Task.FromResult(organisation));

            //Act
            var response = await _organisationsController.GetOrganisation(1);

            //Assert
            Assert.IsInstanceOf <OkObjectResult>(response.Result);
            var result = response.Result as OkObjectResult;

            Assert.IsInstanceOf <OrganisationDto>(result.Value);
            var value = result.Value as OrganisationDto;

            Assert.AreEqual(organisation.Id, value.Id);
            Assert.AreEqual(organisation.Name, value.Name);
            Assert.AreEqual(projects.Count, value.ProjectCount);
        }