コード例 #1
0
ファイル: FlyOwnerServiceTest.cs プロジェクト: pasena/FlyanDo
        public void CanInsertOwner()
        {
            var ownerRepository = new Mock<IFlyOwnerRepository>();
            var ownerService = new FlyOwnerService(ownerRepository.Object);

            ownerService.Insert(new FlyOwner { Name = "Firt Owner", NickName = "Nick" });

            ownerRepository.Verify(v => v.Insert(It.IsAny<FlyOwner>()), Times.Once());
        }
コード例 #2
0
ファイル: FlyOwnerServiceTest.cs プロジェクト: pasena/FlyanDo
        public void CanNotInsertWithoutName()
        {
            var ownerRepository = new Mock<IFlyOwnerRepository>();
            var ownerService = new FlyOwnerService(ownerRepository.Object);

            try
            {
                ownerService.Insert(new FlyOwner { Name = string.Empty });

                Assert.Fail("Validation not implemented!");
            }
            catch (ArgumentException argex)
            {
                Assert.AreEqual("Name is required!", argex.Message);
                ownerRepository.Verify(v => v.Insert(It.IsAny<FlyOwner>()), Times.Never());
            }
        }