Ejemplo n.º 1
0
        public void FindByIdReturnsNothing()
        {
            var fakeTransactionType = new TransactionType[]
            {
                new TransactionType { Id = 1, Name="FakeTransaction1" },
                new TransactionType { Id = 2, Name="FakeTransaction2" },
            };
            var options = new DbContextOptionsBuilder().Options;
            var context = new Mock<AccountingContext>(options);
            context.Setup(x => x.TransactionTypes).ReturnsDbSet(fakeTransactionType);
            context.Setup(i => i.Set<TransactionType>()).ReturnsDbSet(fakeTransactionType);
            var sut = new MockBaseRepository<TransactionType>(context.Object);

            var result = sut.FindById(3);

            result.Should().BeNull("the TransactionType should'nt therefore nothing should be returned i.e Be Null");
        }
Ejemplo n.º 2
0
        public void FindByIdReturnsARecord()
        {
            var fakeTransactionType = new TransactionType[]
            {
                new TransactionType { Id = 1, Name="FakeTransaction1" },
                new TransactionType { Id = 2, Name="FakeTransaction2" },
            };
            var options = new DbContextOptionsBuilder().Options;
            var context = new Mock<AccountingContext>(options);
            context.Setup(x => x.TransactionTypes).ReturnsDbSet(fakeTransactionType);
            context.Setup(i => i.Set<TransactionType>()).ReturnsDbSet(fakeTransactionType);
            var sut = new MockBaseRepository<TransactionType>(context.Object);

            var result = sut.FindById(1);

            result.Should().NotBeNull("the TransactionType should exist therefore should be returned and not be Null");
            result.Id.ShouldBeEquivalentTo(1, "this is the ID we used to retrieve the TransactionType");
        }