Beispiel #1
0
        public static async Task AddOrUpdateServiceRecipients_AddServiceRecipients(
            List <ServiceRecipient> serviceRecipients,
            ServiceRecipientService service)
        {
            var result = await service.AddOrUpdateServiceRecipients(serviceRecipients);

            result.Should().Contain(serviceRecipients.ToDictionary(r => r.OdsCode));
        }
Beispiel #2
0
        public static async Task GetAllOrderItemRecipient_ReturnsNull(
            CallOffId callOffId,
            ServiceRecipientService service)
        {
            var result = await service.GetAllOrderItemRecipients(callOffId);

            result.Should().BeNull();
        }
Beispiel #3
0
        public static async Task GetAllOrderItemRecipient_ReturnsEmptyList(
            [Frozen] ApplicationDbContext context,
            Order order,
            ServiceRecipientService service)
        {
            context.Order.Add(order);
            await context.SaveChangesAsync();

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

            result.Should().BeEmpty();
        }
Beispiel #4
0
        public static async Task AddOrUpdateServiceRecipients_ReturnsExpectedServiceRecipients(
            [Frozen] ApplicationDbContext context,
            List <ServiceRecipient> serviceRecipients,
            ServiceRecipientService service)
        {
            context.ServiceRecipient.AddRange(serviceRecipients);
            await context.SaveChangesAsync();

            var result = await service.AddOrUpdateServiceRecipients(serviceRecipients);

            result.Values.Should().BeEquivalentTo(serviceRecipients);
        }
Beispiel #5
0
        public static async Task AddOrUpdateServiceRecipients_UpdateServiceRecipients(
            [Frozen] ApplicationDbContext context,
            List <ServiceRecipient> serviceRecipients,
            ServiceRecipientService service)
        {
            context.ServiceRecipient.AddRange(serviceRecipients);
            await context.SaveChangesAsync();

            serviceRecipients.OrderBy(s => s.OdsCode).First().Name = "Recipient A";

            await service.AddOrUpdateServiceRecipients(serviceRecipients);

            var resultServiceRecipients = context.Set <ServiceRecipient>().OrderBy(s => s.OdsCode).First();

            serviceRecipients.OrderBy(s => s.OdsCode).First().Name.Should().BeEquivalentTo(resultServiceRecipients.Name);
        }
Beispiel #6
0
        public static async Task GetAllOrderItemRecipient_ReturnsOrderItemRecipients(
            [Frozen] ApplicationDbContext context,
            [Frozen] Order order,
            OrderItem orderItem,
            List <OrderItemRecipient> orderItemRecipients,
            ServiceRecipientService service)
        {
            orderItem.SetRecipients(orderItemRecipients);
            order.AddOrUpdateOrderItem(orderItem);
            context.Order.Add(order);
            await context.SaveChangesAsync();

            var expectedServiceRecipients =
                orderItemRecipients.Select(o => new ServiceRecipient(o.Recipient.OdsCode, o.Recipient.Name));

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

            result.Should().BeEquivalentTo(expectedServiceRecipients);
        }
 public static void Constructor_NullOrderItemValidator_ThrowsArgumentNullException(
     ApplicationDbContext context,
     ServiceRecipientService serviceRecipientService)
 {
     Assert.Throws <ArgumentNullException>(() => _ = new CreateOrderItemService(context, null, serviceRecipientService));
 }
 public static void Constructor_NullDbContext_ThrowsArgumentNullException(
     OrderItemValidator orderItemValidator,
     ServiceRecipientService serviceRecipientService)
 {
     Assert.Throws <ArgumentNullException>(() => _ = new CreateOrderItemService(null, orderItemValidator, serviceRecipientService));
 }
Beispiel #9
0
 public static void Constructor_NullAccessor_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => _ = new ServiceRecipientService(null));
 }