public void SetUp() { var database = new Mock <IDatabase>(); database.Setup(x => x.Query <VoucherRecord>()).Returns(() => new List <VoucherRecord>()); var subject = new VoucherRepository(database.Object); _result = subject.GetVoucherById(1); }
public void SetUp() { var database = new Mock <IDatabase>(); database.Setup(x => x.Query <VoucherRecord>()).Throws(new Exception("Something went wrong")); var subject = new VoucherRepository(database.Object); _result = subject.GetVoucherById(1); }
public void SetUp() { var database = new Mock <IDatabase>(); database.Setup(x => x.Query <VoucherRecord>()).Returns(() => new List <VoucherRecord> { new VoucherRecord { Id = 1, Title = "GREAT DEAL!", Price = "1200", Code = "SOME_VOUCHER_CODE", Quantity = 2, OnlyNamed = true }, new VoucherRecord { Id = 2 } }); database.Setup(x => x.Query <VoucherDeliveryTypeRecord>()).Returns(() => new List <VoucherDeliveryTypeRecord> { new VoucherDeliveryTypeRecord { Id = 3, Voucher = new VoucherRecord { Id = 1 }, DeliveryType = new DeliveryTypeRecord { Id = 1, Name = "Collection" } }, new VoucherDeliveryTypeRecord { Id = 4, Voucher = new VoucherRecord { Id = 1 } } }); database.Setup(x => x.Query <VoucherSizeRecord>()).Returns(() => new List <VoucherSizeRecord> { new VoucherSizeRecord { Id = 5, Voucher = new VoucherRecord { Id = 1 }, Size = new SizeRecord { Id = 1 } }, new VoucherSizeRecord { Id = 6, Voucher = new VoucherRecord { Id = 1 } } }); var subject = new VoucherRepository(database.Object); _result = subject.GetVoucherById(1); }