예제 #1
0
        public void AddRange_ShouldSucceed_WithUnusedIds(string ownerId1, string firstName1, string lastName1, string ownerId2, string firstName2, string lastName2)
        {
            //Arrange
            Guid wrongGuid  = Guid.Parse("c3b922ac-a2bf-4b75-a9dc-5b3c44798264");
            Guid ownerGuid1 = Guid.Parse(ownerId1);
            Guid ownerGuid2 = Guid.Parse(ownerId2);

            _mockOwnerRepository.Setup(x => x.FindAsync(It.IsAny <Expression <Func <tblOwner, bool> > >()))
            .ReturnsAsync(Enumerable.Empty <tblOwner>());

            tblOwner owner1 = new tblOwner()
            {
                Id = ownerGuid1, FirstName = firstName1, LastName = lastName1
            };
            tblOwner owner2 = new tblOwner()
            {
                Id = ownerGuid2, FirstName = firstName2, LastName = lastName2
            };
            var entities = new tblOwner[] { owner1, owner2 };

            //Act
            var result = _service.AddRange(entities);

            //Assert
            _mockOwnerRepository.Verify(x => x.FindAsync(It.IsAny <Expression <Func <tblOwner, bool> > >()), Times.Once());
            _mockOwnerRepository.Verify(x => x.AddRange(entities), Times.Once());
            Assert.True(result.IsCompletedSuccessfully);
        }