public async Task GetAllAsync_WithSolution_ReturnsOkayResult()
        {
            const string expectedDescription = "A description";

            var context = CatalogueSolutionsControllerTestContext.Setup();

            context.Order.SetDescription(OrderDescription.Create(expectedDescription).Value);

            var serviceRecipients = new List <(string Ods, string Name)>
            {
                ("eu", "EU test")
            };

            context.Order.SetServiceRecipient(serviceRecipients, Guid.Empty, string.Empty);

            var orderItem = OrderItemBuilder.Create().WithOdsCode(serviceRecipients[0].Ods).Build();

            context.Order.AddOrderItem(orderItem, Guid.Empty, string.Empty);

            var result = await context.Controller.GetAllAsync("myOrder");

            result.Value.Should().BeOfType <CatalogueSolutionsModel>();
            var model = result.Value;

            model.CatalogueSolutions.Count().Should().Be(1);

            var expectedCatalogueSolutionList = new List <CatalogueSolutionModel>
            {
                CreateCatalogueSolutionModel(orderItem, serviceRecipients[0])
            };

            model.OrderDescription.Should().Be(expectedDescription);
            model.CatalogueSolutions.Should().BeEquivalentTo(expectedCatalogueSolutionList);
        }
        public async Task UpdateAsync_ForExistingOrder_UpdatesCatalogueSolutionsViewed()
        {
            var context = CatalogueSolutionsControllerTestContext.Setup();
            var result  = await context.Controller.UpdateAsync("myOrder");

            result.Should().BeOfType <NoContentResult>();
            context.Order.CatalogueSolutionsViewed.Should().BeTrue();
        }
        public async Task UpdateAsync_InvalidPrimaryOrganisationId_ReturnsForbid()
        {
            var context = CatalogueSolutionsControllerTestContext.Setup();

            context.Order.OrganisationId = Guid.NewGuid();
            var result = await context.Controller.UpdateAsync("myOrder");

            result.Should().BeOfType <ForbidResult>();
        }
        public async Task UpdateAsync_OrderNotFound_ReturnsNotFound()
        {
            var context = CatalogueSolutionsControllerTestContext.Setup();

            context.Order = null;
            var result = await context.Controller.UpdateAsync("myOrder");

            result.Should().BeOfType <NotFoundResult>();
        }
        public async Task GetAllAsync_WithDescriptionAndNoSolution_ReturnsOkResult()
        {
            const string expectedDescription = "A description";
            var          context             = CatalogueSolutionsControllerTestContext.Setup();

            context.Order.SetDescription(OrderDescription.Create(expectedDescription).Value);

            var result = await context.Controller.GetAllAsync("myOrder");

            result.Value.Should().BeOfType <CatalogueSolutionsModel>();
            var model = result.Value;

            model.CatalogueSolutions.Should().BeEmpty();
            model.OrderDescription.Should().Be(expectedDescription);
        }