コード例 #1
0
        public static void Constructor_String_String_InitializesName(string name)
        {
            var recipient = new ServiceRecipient(null, name);

            recipient.Name.Should().Be(name);
            recipient.OdsCode.Should().BeNull();
        }
コード例 #2
0
        public async Task GivenAnAssociatedServiceWithAFlatPriceDeclarativeOrderTypeIsSavedToTheOrder()
        {
            var order     = (Order)Context[ContextKeys.CreatedOrder];
            var orderItem = await OrderItemHelper.CreateOrderItem(
                order,
                CatalogueItemType.AssociatedService,
                CataloguePriceType.Flat,
                ProvisioningType.Declarative,
                DbContext,
                Test.BapiConnectionString);

            var recipients = new List <OrderItemRecipient>();

            var recipient = new ServiceRecipient(order.OrderingParty.OdsCode, order.OrderingParty.Name);

            var orderItemRecipient = new OrderItemRecipient
            {
                Recipient    = recipient,
                DeliveryDate = DateTime.UtcNow,
                Quantity     = new Random().Next(1, 101),
            };

            recipients.Add(orderItemRecipient);

            await OrderItemHelper.AddRecipientToOrderItem(orderItem, recipients, DbContext);

            order.AddOrUpdateOrderItem(orderItem);

            DbContext.Update(order);
            await DbContext.SaveChangesAsync();

            Context.Remove(ContextKeys.CreatedOrder);
            Context.Add(ContextKeys.CreatedOrder, order);
        }
コード例 #3
0
        public static void Constructor_String_String_InitializesOdsCode(string odsCode)
        {
            var recipient = new ServiceRecipient(odsCode, null);

            recipient.OdsCode.Should().Be(odsCode);
            recipient.Name.Should().BeNull();
        }
        public void ThenTheRecipientNameODSCodeOfEachItemIsTheConcatenation()
        {
            var name = Test.Pages.PreviewOrderSummary.GetItemRecipientName();
            var expectedServiceRecipient = new ServiceRecipient(string.Empty, string.Empty); // placeholder until I can access the preview page
            var expectedValue            = string.Format("{0} ({1})", expectedServiceRecipient.Name, expectedServiceRecipient.OdsCode);

            name.Should().Be(expectedValue);
        }
コード例 #5
0
        private static IEnumerable <ITestCaseData> EqualityTestCases()
        {
            const string odsCode = "ODS";

            var a = new ServiceRecipient(odsCode, null);

            yield return(new TestCaseData(a, a, true));

            yield return(new TestCaseData(a, new ServiceRecipient(odsCode, null), true));

            yield return(new TestCaseData(a, new ServiceRecipient("PDS", null), false));
        }
コード例 #6
0
        public static void Equals_DifferentType_ReturnsFalse()
        {
            var recipient     = new ServiceRecipient("ODS", null);
            var anonRecipient = new
            {
                recipient.OdsCode,
            };

            var isEqual = recipient.Equals(anonRecipient);

            isEqual.Should().BeFalse();
        }
        public static async Task GetServiceRecipientsByParentOdsCode_SinglePage_ReturnsOrganisation()
        {
            var context = ServiceRecipientTestContext.Setup();

            context.Settings.GetChildOrganisationSearchLimit = 2;
            var childOrg = new ServiceRecipient {
                Name = "Organisation 1", PrimaryRoleId = "RO177", OrgId = "ABC"
            };
            var json = CreatePageJson(childOrg);

            context.Http.RespondWith(status: 200, body: json);

            var response = await context.Repository.GetServiceRecipientsByParentOdsCode(OdsCode);

            response.Should().BeEquivalentTo(new[] { childOrg });
        }
        public static void Constructor_NullUnitTime_InitializesUnitTime(
            Order order,
            CatalogueItem catalogueItem,
            PricingUnit pricingUnit,
            ServiceRecipient recipient)
        {
            var orderItem = new FlattenedOrderItem
            {
                CatalogueItem = catalogueItem,
                Order         = order,
                PricingUnit   = pricingUnit,
                Recipient     = recipient,
            };

            var odooOrderItem = new OdooOrderItem(orderItem);

            odooOrderItem.UnitTime.Should().BeNull();
        }
コード例 #9
0
        public async Task GivenAnAssociatedServiceWithAFlatPriceVariableOn_DemandOrderTypeWithTheQuantityPeriodPerYearIsSavedToTheOrder()
        {
            await SetOrderCatalogueSectionToComplete();

            var order = (Order)Context[ContextKeys.CreatedOrder];

            var orderItem = await OrderItemHelper.CreateOrderItem(
                order,
                CatalogueItemType.AssociatedService,
                CataloguePriceType.Flat,
                ProvisioningType.OnDemand,
                DbContext,
                Test.BapiConnectionString,
                TimeUnit.PerYear);

            var recipients = new List <OrderItemRecipient>();

            var recipient = new ServiceRecipient(order.OrderingParty.OdsCode, order.OrderingParty.Name);

            var orderItemRecipient = new OrderItemRecipient
            {
                Recipient    = recipient,
                DeliveryDate = DateTime.UtcNow,
                Quantity     = new Random().Next(1, 101),
            };

            recipients.Add(orderItemRecipient);

            await OrderItemHelper.AddRecipientToOrderItem(orderItem, recipients, DbContext);

            var selectedRecipients = new List <SelectedServiceRecipient>();

            selectedRecipients.AddRange(recipients.Select(r => new SelectedServiceRecipient {
                Recipient = r.Recipient
            }));

            order.AddOrUpdateOrderItem(orderItem);

            DbContext.Update(order);
            await DbContext.SaveChangesAsync();

            Context.Remove(ContextKeys.CreatedOrder);
            Context.Add(ContextKeys.CreatedOrder, order);
        }
        public async Task GetServiceRecipientsByParentOdsCode_SinglePageDifferentRoleIds_ReturnsOnlyMatching()
        {
            var context = ServiceRecipientTestContext.Setup();

            context.Settings.GetChildOrganisationSearchLimit = 3;
            var childOne = new ServiceRecipient {
                Name = "Organisation 1", PrimaryRoleId = "RO177", OrgId = "ABC"
            };
            var childTwo = new ServiceRecipient {
                Name = "Organisation 2", PrimaryRoleId = "RO178", OrgId = "ABD"
            };
            var jsonPageOne = CreatePageJson(childOne, childTwo);

            context.Http.RespondWith(status: 200, body: jsonPageOne);

            var response = await context.Repository.GetServiceRecipientsByParentOdsCode(OdsCode);

            response.Should().BeEquivalentTo(childOne);
        }
        public static void Constructor_DeclarativeProvisioningType_InitializesEstimationPeriod(
            Order order,
            CatalogueItem catalogueItem,
            PricingUnit pricingUnit,
            ServiceRecipient recipient)
        {
            var orderItem = new FlattenedOrderItem
            {
                CatalogueItem    = catalogueItem,
                Order            = order,
                PricingUnit      = pricingUnit,
                ProvisioningType = ProvisioningType.Declarative,
                Recipient        = recipient,
            };

            var odooOrderItem = new OdooOrderItem(orderItem);

            odooOrderItem.EstimationPeriod.Should().BeNull();
        }
        public static async Task GetServiceRecipientsByParentOdsCode_MultiplePage_ReturnsAllOrganisations()
        {
            var context = ServiceRecipientTestContext.Setup();

            context.Settings.GetChildOrganisationSearchLimit = 1;
            var childOne = new ServiceRecipient {
                Name = "Organisation 1", PrimaryRoleId = "RO177", OrgId = "ABC"
            };
            var childTwo = new ServiceRecipient {
                Name = "Organisation 2", PrimaryRoleId = "RO177", OrgId = "ABD"
            };
            var jsonPageOne   = CreatePageJson(childOne);
            var jsonPageTwo   = CreatePageJson(childTwo);
            var jsonPageThree = CreatePageJson();

            context.Http.RespondWith(status: 200, body: jsonPageOne);
            context.Http.RespondWith(status: 200, body: jsonPageTwo);
            context.Http.RespondWith(status: 200, body: jsonPageThree);

            var response = await context.Repository.GetServiceRecipientsByParentOdsCode(OdsCode);

            response.Should().BeEquivalentTo(new[] { childOne, childTwo });
        }
コード例 #13
0
        public ActionResult Create(CreateRecipientViewModel model)
        {
            var newRecipient = new ServiceRecipient();
            var newAddress   = new Address();

            newAddress.Address1 = model.Address1;
            newAddress.Address2 = model.Address2;
            newAddress.City     = model.City;
            newAddress.State    = model.State;
            newAddress.Zip      = model.Zip;

            addressRepo.Save(newAddress);

            newRecipient.AddressId          = newAddress.Id;
            newRecipient.OrganizationName   = model.OrganizationName;
            newRecipient.Description        = model.Description;
            newRecipient.OrganizationTypeId = 5;
            newRecipient.UserId             = User.Identity.GetUserId();

            recipientRepo.Save(newRecipient);

            return(RedirectToAction("Details", new { id = newRecipient.Id }));
        }
コード例 #14
0
        public static void GetHashCode_ReturnsExpectedResult(ServiceRecipient a, ServiceRecipient b, bool expectedResult)
        {
            var isEqual = a.GetHashCode() == b.GetHashCode();

            isEqual.Should().Be(expectedResult);
        }
コード例 #15
0
        public static void Equals_ReturnsExpectedResult(ServiceRecipient a, ServiceRecipient b, bool expectedResult)
        {
            var isEqual = a.Equals(b);

            isEqual.Should().Be(expectedResult);
        }