Beispiel #1
0
        public async Task When_AddContact_Then_ObjectFromRepositoryIsPresent()
        {
            // Arrange
            var mockRepo = new Mock <ICompanyRepository>();

            mockRepo.Setup(repo => repo.AddContact(It.IsAny <Guid>(), It.IsAny <Guid>()))
            .ReturnsAsync(true);

            var guid    = Guid.NewGuid();
            var company = new Company()
            {
                Id = guid, Name = guid.ToString().Substring(10), VAT = guid.ToString().Substring(1, 5)
            };

            mockRepo.Setup(repo => repo.GetById(It.IsAny <Guid>()))
            .ReturnsAsync(company);

            var controller = new CompanyController(mockRepo.Object, null);

            // Act
            var result = await controller.AddContact(It.IsAny <Guid>(), It.IsAny <Guid>());

            // Check
            Assert.IsNotNull(result);
            Assert.AreEqual(company, result);
        }