public void CheckParametersChecksIfProductOrdersIsEmptyEvenIfPreviousConditionsAreNotMet()
        {
            var navOrderUnderTest = new NavOrder();
            var expected = ErrorGuids.NoProductsInOrderGuid;

            var query= navOrderUnderTest.CheckParameters();

            var actual = IsExpectedErrorGuidInQueryResults(query, expected);
            Assert.IsTrue(actual.Any());
        }
Ejemplo n.º 2
0
        public LicenseMessage[] LicenseImport(NavOrder navOrder)
        {
            var licenseKeyList = navOrder.ProductOrders.Select(productOrder => productOrder.LicenseKey).ToList();
            var licenseList = _licenseRepository.GetLicensesByLicenseKeys(licenseKeyList);

            var validationMessages = navOrder.ValidateThis(licenseList);//TODO: entered:20150825. ValidateThis should throw exceptions instead of sending back license messages.

            if (validationMessages.Any()) return validationMessages.ToArray();

            validationMessages = navOrder.Action == (int) ActionEnum.Create ? CreateNewProductsForOrder(navOrder) : UpdateProductsForOrder(navOrder);

            return validationMessages.ToArray();
        }
        public void DoExistingUsersExceedUsersInOrderReturnsErrorIfAssignedUsersIsGreaterThanUsersInOrder()
        {
            var navOrderUnderTest = new NavOrder();
            const string existingLicenseKey = "ExistingLicenseKey";
            navOrderUnderTest.ProductOrders.Add(new ProductOrder { ExpirationDate = DateTime.Now, LicenseKey = existingLicenseKey,NumberOfUsers = 1});
            var existingUsers = new List<UserData>{
                    new UserData{UserId = new Guid()},
                    new UserData{UserId = new Guid()},
                    new UserData{UserId = new Guid()},
                };

            var existingLicenses = new List<License> {new License{LicenseKey = existingLicenseKey,Users = existingUsers}};
            var expected = ErrorGuids.NumberOfAssignedUsersExceedsLicensedUsersInOrderGuid;

            var query=navOrderUnderTest.DoExistingUsersExceedUsersInOrder(existingLicenses);

            var actual = IsExpectedErrorGuidInQueryResults(query, expected);

            Assert.IsTrue(actual.Any());
        }
        public void DoOrderNumbersMatchExistingLicenseOrderNumbersReturnsNullIfExistingLicensesHaveSameOrderNumbers()
        {
            const string firstExistingKey = "firstExistingLicenseKey";
            const string nextExistingKey = "nextExistingLicenseKey";
            const string firstExistingOrderNumber = "1234";
            var expected = ErrorGuids.OrderNumberDoesntMatchGuid;
            var existingLicenseList = new List<License>
            {
                new License{LicenseKey = firstExistingKey, OrderNumber = firstExistingOrderNumber},
                new License{LicenseKey = nextExistingKey, OrderNumber = firstExistingOrderNumber},
            };

            IList<ProductOrder> productOrdersUnderTest = new List<ProductOrder>{

                    new ProductOrder{LicenseKey = firstExistingKey},
                    new ProductOrder{LicenseKey = nextExistingKey}
                };
            var orderUnderTest = new NavOrder
            {
                OrderNumber = firstExistingOrderNumber,
                ProductOrders = productOrdersUnderTest
            };

            var query = orderUnderTest.DoOrderNumbersMatchExistingLicenseOrderNumbers(existingLicenseList);
            var actual = IsExpectedErrorGuidInQueryResults(query, expected);

            Assert.IsTrue(!actual.Any());
        }
        public void CheckParametersDoesntThrowExceptionWhenOrderNumberIsMissingAndLaterChecksAreRun()
        {
            var navOrderUnderTest = new NavOrder {Action = 5};

            navOrderUnderTest.CheckParameters();
        }
        public void ValidateUpdateOrderCatchesMissingLicensesWhenOtherIssuesAreNotPresent()
        {
            var navOrderUnderTest = new NavOrder();
            const string testLicenseKey = "ExistingLicense";
            const string nonPresentLicenseKey = "NonExistingLicense";
            var expected = ErrorGuids.LicenseKeyDoesntExist;
            var existingLicenses = new List<License>() { new License { LicenseKey = nonPresentLicenseKey } };
            navOrderUnderTest.ProductOrders.Add(new ProductOrder { LicenseKey = testLicenseKey });

            var query = navOrderUnderTest.ValidateUpdateOrder(existingLicenses);
            var actual = IsExpectedErrorGuidInQueryResults(query, expected);

            Assert.IsTrue(actual.Any());
        }
        public void ValidateOrdersForNewLicenseFlagsMissingLicenseKeysAndAlreadyExistingOnes()
        {
            var navOrderUnderTest = new NavOrder();
            const string existingLicenseName = "ExistingLicense";
            var expectedError1 = ErrorGuids.LicenseKeyIsEmptyGuid;
            var expectedError2 = ErrorGuids.LicenseKeyAlreadyAssigned;
            navOrderUnderTest.ProductOrders.Add(new ProductOrder { ExpirationDate = DateTime.Now });
            navOrderUnderTest.ProductOrders.Add(new ProductOrder{ExpirationDate = DateTime.Now,LicenseKey =existingLicenseName});
            var existingLicenses = new List<string> {existingLicenseName};

            var query = navOrderUnderTest.ValidateOrderForNewLicense(existingLicenses);

            var actualFirstCondition = IsExpectedErrorGuidInQueryResults(query, expectedError1);
            var actualSecondCondition = IsExpectedErrorGuidInQueryResults(query, expectedError2);
            Assert.IsTrue(actualFirstCondition.Any());
            Assert.IsTrue(actualSecondCondition.Any());
        }
        public void ValidateOrdersFlagsMissingLicenseKeys()
        {
            var navOrderUnderTest = new NavOrder();
            var expected = ErrorGuids.LicenseKeyIsEmptyGuid;
            navOrderUnderTest.ProductOrders.Add(new ProductOrder{ExpirationDate = DateTime.Now});

            var existingLicenses = new List<string>();
            var query = navOrderUnderTest.ValidateOrderForNewLicense(existingLicenses);

            var actual = IsExpectedErrorGuidInQueryResults(query, expected);
            Assert.IsTrue(actual.Any());
        }
        public void IfNumberOfUsersExceeds5000ReturnMessage()
        {
            var navOrderUnderTest = new NavOrder();
            const int usersToPassToOrder = 5001;
            navOrderUnderTest.ProductOrders.Add(new ProductOrder{NumberOfUsers = usersToPassToOrder});
            var expected = ErrorGuids.NumberOfUsersIsInvalid;

            var query = navOrderUnderTest.DoesNumberOfUsersExceed5000();

            var actual = IsExpectedErrorGuidInQueryResults(query, expected);

            Assert.IsTrue(actual.Any());
        }
        public void IfNavOrdersContainEmptyLicenseKeyReturnMessage()
        {
            var x = new NavOrder();
            x.ProductOrders.Add(new ProductOrder{ExpirationDate = DateTime.Now});
            var expected = ErrorGuids.LicenseKeyIsEmptyGuid;
            var query = x.AreThereEmptyLicenseKeys();

            var actual = IsExpectedErrorGuidInQueryResults(query, expected);

            Assert.IsTrue(actual.Any());
        }
        public void IfNavOrderContainsEmptyProductOrdersReturnMessage()
        {
            var x = new NavOrder();
            var expected = ErrorGuids.NoProductsInOrderGuid;

            var actual = x.IsProductOrdersEmpty().Code;

            Assert.AreEqual(expected, actual);
        }
        public void IfLicenseKeyInOrderNotExistsInPassedArrayReturnMessage()
        {
            var x = new NavOrder();
            const string testLicenseKey = "ExistingLicense";
            const string nonPresentLicenseKey = "NonExistingLicense";
            var expected = ErrorGuids.LicenseKeyDoesntExist;
            var existingLicenses = new List<License>() {new License{LicenseKey = nonPresentLicenseKey}};
            x.ProductOrders.Add(new ProductOrder { LicenseKey = testLicenseKey });
            var query = x.DoesLicenseKeyExistForUpdate(existingLicenses);
            var actual = IsExpectedErrorGuidInQueryResults(query, expected);

            Assert.IsTrue(actual.Any());
        }
        public void IfLicenseKeyInOrderExistsInPassedArrayReturnMessage()
        {
            var x = new NavOrder();
            const string testLicenseKey = "testLicenseKey";
            x.ProductOrders.Add(new ProductOrder{LicenseKey = testLicenseKey});
            var expected = ErrorGuids.LicenseKeyAlreadyAssigned;
            var existingLicenseKeys = new List<string> {testLicenseKey};

            var query = x.DoesProductListContainLicenseKey(existingLicenseKeys);
            var actual = IsExpectedErrorGuidInQueryResults(query, expected);

            Assert.IsTrue(actual.Any());
        }
Ejemplo n.º 14
0
 private List<LicenseMessage> UpdateProductsForOrder(NavOrder navOrder)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
 private List<LicenseMessage> CreateNewProductsForOrder(NavOrder navOrder)
 {
     return navOrder.ProductOrders.Select(productOrder => new LicenseMessage
     {
         Code = SuccessGuids.CreatedGuid,
         Message = "Added license for product:" + productOrder.ProductName,
         MessageValues = CreateLicenseForOrder(productOrder,navOrder.OrderNumber).ConvertToMessageValueArray(),
         Severity = (int) MessageStateEnum.Information
     }).ToList();
 }