Example #1
0
 public static void SetSupplierSection_NullOrder_ThrowsException(
     Supplier supplier,
     Contact contact,
     SupplierSectionService service)
 {
     Assert.ThrowsAsync <ArgumentNullException>(async() => await service.SetSupplierSection(null, supplier, contact));
 }
Example #2
0
 public static void SetSupplierSection_NullContact_ThrowsException(
     Order order,
     Supplier supplier,
     SupplierSectionService service)
 {
     Assert.ThrowsAsync <ArgumentNullException>(async() => await service.SetSupplierSection(order, supplier, null));
 }
Example #3
0
        public static async Task GetOrder_ReturnsNull(
            CallOffId callOffId,
            SupplierSectionService service)
        {
            var result = await service.GetOrder(callOffId);

            result.Should().BeNull();
        }
Example #4
0
        public static async Task GetOrder_ReturnsOrder(
            [Frozen] ApplicationDbContext context,
            Order order,
            SupplierSectionService service)
        {
            context.Order.Add(order);
            await context.SaveChangesAsync();

            var result = await service.GetOrder(order.CallOffId);

            result.Should().BeEquivalentTo(order);
        }
Example #5
0
        public static async Task SetSupplierSection_UpdatesSupplierContact(
            [Frozen] ApplicationDbContext context,
            [Frozen] Contact contact,
            Order order,
            Supplier supplier,
            SupplierSectionService service)
        {
            context.Order.Add(order);
            context.Supplier.Add(supplier);
            await context.SaveChangesAsync();

            var expected = order.SupplierContact;
            await service.SetSupplierSection(order, supplier, contact);

            expected.Should().Be(contact);
        }
Example #6
0
        public static async Task SetSupplierSection_SavesToDb(
            [Frozen] ApplicationDbContext context,
            [Frozen] Contact contact,
            Order order,
            Supplier supplier,
            SupplierSectionService service)
        {
            context.Order.Add(order);
            context.Supplier.Add(supplier);
            await context.SaveChangesAsync();

            await service.SetSupplierSection(order, supplier, contact);

            var expectedOrder = context.Set <Order>().First(o => o.Equals(order));

            expectedOrder.Supplier.Name.Should().Be(supplier.Name);
            expectedOrder.SupplierContact.Should().Be(contact);
        }
Example #7
0
 public static void Constructor_NullAccessor_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => _ = new SupplierSectionService(null));
 }