Ejemplo n.º 1
0
        /// <summary>
        /// Send a request to read resource. Parse response's xml to ReadResponseData.
        /// </summary>
        /// <param name="resourceType">Resource type</param>
        /// <param name="urlParameters">Url parameters</param>
        /// <returns>List of xml resource</returns>
        public static List <XmlResource> ReadResource(Enums.ResourceType resourceType, Dictionary <string, object> urlParameters, int count = 0)
        {
            ReadResponseData <XmlResource> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToString(), urlParameters);

            Assert.That(result, MustBe.ReadSuccess(count), "Read resource failed!");
            return(result.Items);
        }
        public void TestNoneTelephoneField(Enums.ResourceType resourceType, FieldType fieldType, SameResultSymbolType symbolType)
        {
            int    symbolIndex = GetSymbolIndex(symbolType);
            string fieldName   = customFields.Data[$"{resourceType}-{fieldType}"].Field.Name;

            Dictionary <string, object> urlParam1 = new Dictionary <string, object>()
            {
                [ResourceHelper.Partition] = AuthenticationInfoProvider.Current.DefaultPartition,
                ["keyword"] = KeywordHelper.GetKeywordBasedOnSymbolType(fieldName, symbolType, symbolIndex),
                [ResourceHelper.FieldAlias] = string.Join(",", CommonConstant.NoneTelephoneTextField[resourceType]) + $",{resourceType.ToResourceName()}.P_Id",
            };
            ReadResponseData <XmlResource> result1 = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToResourceName(), urlParam1);

            Assert.That(result1, MustBe.ReadSuccess(1), "Read resource failed!");
            Assert.That(result1.Items.Random().DictionaryValues[customFields.Data[$"{resourceType}-{fieldType}"].Field.ToAlias()],
                        Does.Contain(KeywordHelper.GetFieldValueBasedOnSymbolType(fieldName, symbolType, symbolIndex, false)),
                        "The expected field doesn't contain the expected keyword!");

            Dictionary <string, object> urlParam2 = new Dictionary <string, object>()
            {
                [ResourceHelper.Partition] = AuthenticationInfoProvider.Current.DefaultPartition,
                ["keyword"] = KeywordHelper.GetFieldValueBasedOnSymbolType(fieldName, symbolType, symbolIndex, false),
                [ResourceHelper.FieldAlias] = string.Join(",", CommonConstant.NoneTelephoneTextField[resourceType]) + $",{resourceType.ToResourceName()}.P_Id",
            };
            ReadResponseData <XmlResource> result2 = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToResourceName(), urlParam2);

            Assert.That(result2, MustBe.ReadSuccess(1), "Read resource failed!");

            Assert.IsTrue(ResourceHelper.CompareList(result1.Items, result2.Items, $"{resourceType.ToResourceName()}.P_Id"), "Results are different!");
        }
Ejemplo n.º 3
0
        public void TestReadValidFieldParameters(Enums.ResourceType resourceType, string fieldName, ValidFieldInput valueInput)
        {
            string field = string.Empty;
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { PhaseApiFields.Resource, (int)resourceType },
            };

            if (valueInput == ValidFieldInput.SingleValue)
            {
                field = fieldName;
            }
            else
            {
                field = $"{fieldName},{fieldName},{fieldName},{fieldName}";
            }
            parameters.Add(PhaseApiFields.Field, field);

            XmlHandler result = PublicApiAdapter.CreateAdapterForDefaultConnection().Read <Phase>(parameters) as XmlHandler;

            Assert.NotNull(result, "Failed to parse the server's response!");
            ReadResponseData <Option> parseResult = XmlHelper.ParseXMLString <ReadResponseData <Option> >(result.RawContent);

            Assert.That(parseResult, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, "Phase"));

            //Verify that the result contains field name only
            VerifyFieldParameter(result, fieldName);
        }
Ejemplo n.º 4
0
 public GcThroughputAssertionAttribute(GcMetric metric, GcGeneration generations,
     MustBe condition, double averageOperationsPerSecond)
     : base(metric, generations)
 {
     Condition = condition;
     AverageOperationsPerSecond = averageOperationsPerSecond;
 }
Ejemplo n.º 5
0
        public static string MustBeToString(MustBe condition)
        {
            switch (condition)
            {
            case MustBe.Between:
                return("must be between");

            case MustBe.ExactlyEqualTo:
                return("must be exactly");

            case MustBe.GreaterThan:
                return("must be greater than");

            case MustBe.GreaterThanOrEqualTo:
                return("must be greater than or equal to");

            case MustBe.LessThan:
                return("must be less than");

            case MustBe.LessThanOrEqualTo:
                return("must be less than or equal to");

            default:
                return("(unspecified)");
            }
        }
Ejemplo n.º 6
0
        public static ReadResponseData <XmlResource> GetSingleSearchResult(string resourceType, string fieldAlias, string condition, object firsrCondValue, object secondCondValue, int resultCode, Dictionary <string, object> extraUrlParameters = null)
        {
            string tempCond   = $"{fieldAlias}:{condition}={firsrCondValue}";
            string formatCond = condition == DateTimeValidator.Or ? $"{tempCond}:{secondCondValue}" : tempCond;

            Dictionary <string, object> urlParameters = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition },
                { "condition", formatCond },
                { "field", fieldAlias }
            };

            if (extraUrlParameters != null)
            {
                urlParameters = urlParameters.Concat(extraUrlParameters).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value);
            }

            if (resultCode == Enums.PublicAPIResultCode.DateTimeOutOfRange)
            {
                ErrorCode errorResult = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadFail(resourceType, urlParameters);
                Assert.That(errorResult, MustBe.MatchingErrorCode(resultCode), Enums.Message.WRONG_ERROR_CODE);
                return(null);
            }
            else
            {
                var result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType, urlParameters);
                Assert.That(result, Is.Not.Null, string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType));
                Assert.That(result.Code, Is.EqualTo(resultCode), Enums.Message.WRONG_ERROR_CODE);
                Assert.That(result.Items, Is.Not.Null, string.Format("Read {0}'s resource to be empty!", resourceType));
                return(result);
            }
        }
        public void TestReadInvalidOtherParamItemState(Enums.ResourceType resourceType, ItemState itemState, string parameter, ReadInvalidInput invalidInput, int expectedCode)
        {
            var       parameters = GetUrlParameters(resourceType, itemState, parameter, invalidInput);
            ErrorCode result     = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadFail(resourceType.ToString(), parameters);

            Assert.That(result, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 8
0
 public Assertion(MustBe condition, double value, double?maxValue)
 {
     Contract.Requires(condition != MustBe.Between || (condition == MustBe.Between && maxValue.HasValue));
     Condition = condition;
     Value     = value;
     MaxValue  = maxValue;
 }
Ejemplo n.º 9
0
 public void Assertion_should_correctly_test_against_expected_result(MustBe condition1, double value1, double? maxValue1,
     double testValue, bool expectedValue)
 {
     var assertion1 = new Assertion(condition1, value1, maxValue1);
     var actualValue = assertion1.Test(testValue);
     Assert.Equal(expectedValue, actualValue);
 }
Ejemplo n.º 10
0
 public Assertion(MustBe condition, double value, double? maxValue)
 {
     Contract.Requires(condition != MustBe.Between || maxValue.HasValue);
     Condition = condition;
     Value = value;
     MaxValue = maxValue;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Verify multi search/single field result by resource of system field
        /// </summary>
        /// <param name="resourceType">Resource Type</param>
        /// <param name="searchParameters">Search Paramters Class</param>
        public static void VerifyMultiSearchOneFieldById(Enums.ResourceType resourceType, SearchParameters searchParameters, Dictionary <string, object> extraUrlParameters = null)
        {
            string firstFieldAlias  = searchParameters.FirstFieldAlias;
            string secondFieldAlias = searchParameters.SecondFieldAlias;
            string firstCondition   = searchParameters.FirstCondition;
            string secondCondition  = searchParameters.SecondCondition;
            string firstCondValue   = searchParameters.FirstCondValue.ToString();
            string secondCondValue  = searchParameters.SecondCondValue.ToString();

            ReadResponseData <XmlResource> result = SystemFieldTypeHelper.GetMultipleSearchResult(resourceType, firstFieldAlias, secondFieldAlias, firstCondition, secondCondition, firstCondValue.ToString(), secondCondValue.ToString(), extraUrlParameters);

            Assert.That(result, MustBe.ReadSuccess(0), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType.ToString()));
            Assert.That(result.Count, Is.GreaterThanOrEqualTo(0), Enums.Message.COUNT_ERROR);
            Assert.That(result.Items.Count, Is.GreaterThanOrEqualTo(0), Enums.Message.COUNT_ERROR);

            string realValue = null;

            foreach (var item in result.Items)
            {
                if (firstFieldAlias == $"{resourceType.ToResourceName()}.{DeletedDataFields.P_UpdateBy}" || secondFieldAlias == $"{resourceType.ToResourceName()}.{DeletedDataFields.P_UpdateBy}")
                {
                    XmlResource user = (item.DictionaryValues[$"{resourceType.ToResourceName()}.{DeletedDataFields.P_UpdateBy}"] as XmlResource).DictionaryValues["User"] as XmlResource;
                    realValue = user.DictionaryValues["User.P_Id"].ToString();
                }
                else
                {
                    realValue = item.DictionaryValues[firstFieldAlias].ToString();
                }
                Assert.That(int.Parse(realValue), DateTimeValidator.ConditionsMap[firstCondition](int.Parse(firstCondValue), int.Parse(secondCondValue)).And.Matches(DateTimeValidator.ConditionsMap[secondCondition](int.Parse(secondCondValue), int.Parse(firstCondValue))), DateTimeValidator.ErrorMessage);
            }
        }
Ejemplo n.º 12
0
        public void TestReadPhaseWithDuplicateParameters(string param, bool isDuplicatedValue)
        {
            Enums.ResourceType          job        = Enums.ResourceType.Job;
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
            };

            List <object> duplicatedParameters = new List <object>();

            var parameterValues = new Dictionary <string, object>
            {
                [PhaseApiFields.ResourceId + "1"] = (int)records.Data[$"{job.ToPrivateEnum()}0"].Id,
                [PhaseApiFields.ResourceId + "2"] = (int)records.Data[$"{job.ToPrivateEnum()}1"].Id,
                [PhaseApiFields.Id + "1"]         = PhaseHelper.CreatePhase(job, records.Data[$"{job.ToPrivateEnum()}0"].Id.ToString()),
                [PhaseApiFields.Id + "2"]         = PhaseHelper.CreatePhase(job, records.Data[$"{job.ToPrivateEnum()}1"].Id.ToString()),
                [PhaseApiFields.Resource + "1"]   = (int)Enums.ResourceType.Client,
                [PhaseApiFields.Resource + "2"]   = (int)Enums.ResourceType.Activity,
                [PhaseApiFields.Count + "1"]      = 10,
                [PhaseApiFields.Count + "2"]      = 11,
                [PhaseApiFields.Start + "1"]      = 10,
                [PhaseApiFields.Start + "2"]      = 12,
                [PhaseApiFields.Field + "1"]      = PhaseApiFields.Memo,
                [PhaseApiFields.Field + "2"]      = PhaseApiFields.Phase,
                [PhaseApiFields.Condition + "1"]  = $"{nameof(PhaseApiFields.Id)}:eq={records.Data[$"{job.ToPrivateEnum()}0"].Id}",
                [PhaseApiFields.Condition + "2"]  = $"{nameof(PhaseApiFields.Id)}:eq={records.Data[$"{job.ToPrivateEnum()}1"].Id}",
                [PhaseApiFields.Order + "1"]      = $"{PhaseApiFields.Order}={nameof(PhaseApiFields.Id)}:{records.Data[$"{job.ToPrivateEnum()}0"].Id}",
                [PhaseApiFields.Order + "2"]      = $"{PhaseApiFields.Order}={nameof(PhaseApiFields.Id)}:{records.Data[$"{job.ToPrivateEnum()}1"].Id}",
            };

            if (isDuplicatedValue)
            {
                duplicatedParameters = new List <object>
                {
                    parameterValues[$"{param}1"],
                    parameterValues[$"{param}1"],
                    parameterValues[$"{param}1"],
                };
            }
            else
            {
                duplicatedParameters = new List <object>
                {
                    parameterValues[$"{param}1"],
                    parameterValues[$"{param}2"],
                    parameterValues[$"{param}2"],
                };
            }

            if (param != PhaseApiFields.Resource)
            {
                parameters.Add(PhaseApiFields.Resource, (int)job);
            }
            parameters.Add(param, duplicatedParameters);

            ErrorCode result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadFail <Phase>(parameters);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.ParameterIsInvalid), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 13
0
        private static void ReadAndVerify(Enums.ResourceType resourceType, string fieldAlias, string id, Action <object> verifyActualValue = null)
        {
            ReadResponseData <XmlResource> result = ResourceHelper.ReadResourceById(resourceType, fieldAlias, id);

            Assert.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType));

            verifyActualValue?.Invoke(result.Items[0].DictionaryValues[fieldAlias]);
        }
Ejemplo n.º 14
0
        public static void ReadAndVerify(Enums.ResourceType resourceType, Dictionary <string, ResourceFields.InputType> fieldAlias, string id, int index, HrbcRecordCreator expectedRecords, HrbcFieldReader fieldReader)
        {
            ReadResponseData <XmlResource> result = ResourceHelper.ReadResourceById(resourceType, string.Join(",", fieldAlias.Keys), id);

            Assert.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType));

            VerifyFieldValue(resourceType, fieldAlias, result.Items[0], index, expectedRecords, fieldReader);
        }
        private static void ReadAndVerify(Enums.ResourceType resourceType, string fieldAlias, string id, string expectedValue)
        {
            ReadResponseData <XmlResource> result = ResourceHelper.ReadResourceById(resourceType, fieldAlias, id);

            Assert.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType));

            Assert.That(result.Items[0].DictionaryValues[fieldAlias], MustBe.EqualTo(expectedValue), "The field value is not written correctly!");
        }
        private void ReadAndVerify(Enums.ResourceType resourceType, string fieldAlias, string id)
        {
            ReadResponseData <XmlResource> result = ResourceHelper.ReadResourceById(resourceType, fieldAlias, id);

            Assert.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType));

            VerifyFieldValue(resourceType, fieldAlias, result.Items[0].DictionaryValues[fieldAlias]);
        }
Ejemplo n.º 17
0
        public void TestReadSpecialInvalidInput(ReadSpecialInvalidInput invalidInput, int expectedCode)
        {
            Dictionary <string, object> urlParameters = GetUrlParameter(invalidInput);

            ErrorCode result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadFail <Partition>(urlParameters);

            Assert.That(result, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 18
0
        public void TestCreateSingleItem(Enums.ResourceType resourceType, string fieldName, InjectionInput fieldType)
        {
            XmlResource resource = ResourceHelper.CreateSingleResourceItem(resourceType, $"{resourceType.ToResourceName()}.{fieldName}",
                                                                           InjectionInputData.InjectionInputMapper[fieldType], records, true);
            ErrorCode result = ResourceHelper.WriteResourceFail(resource, cleaner);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE);
        }
        public void TestCreateListItem(Enums.ResourceType resourceType, string fieldValue)
        {
            List <XmlResource> resources = ResourceHelper.CreateListResourceItem(resourceType,
                                                                                 $"{resourceType.ToResourceName()}.{AppField}", fieldValue, records);
            List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resources, cleaner);

            Assert.That(result, MustBe.SuccessfullyWritten(resources.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
Ejemplo n.º 20
0
        public void Assertion_should_correctly_test_against_expected_result(MustBe condition1, double value1, double?maxValue1,
                                                                            double testValue, bool expectedValue)
        {
            var assertion1  = new Assertion(condition1, value1, maxValue1);
            var actualValue = assertion1.Test(testValue);

            Assert.Equal(expectedValue, actualValue);
        }
        public void TestCreateListItem(Enums.ResourceType resourceType, WriteValidInput valueType)
        {
            string             fieldAlias   = resourceType.ToResourceName() + "." + AppField;
            List <XmlResource> resourceList = ResourceHelper.CreateListResourceItem(resourceType, fieldAlias, FieldValueMapper.ValidInputMapper[valueType], records, true);

            List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner);

            Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), "The response data is incorrect!");
        }
Ejemplo n.º 22
0
        private void PrepareData(Enums.ResourceType resourceType, string fieldAlias, string updateId, long fieldValue)
        {
            XmlResource resource = ResourceHelper.CreateUpdatedResource(resourceType, updateId, fieldAlias, fieldValue);
            string      id       = ResourceHelper.WriteResource(resource, null);

            //Verify result
            Assume.That(id, MustBe.Not.Null.And.Not.Empty, string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assume.That(id, MustBe.EqualTo(updateId), string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
Ejemplo n.º 23
0
        public void TestCreateSingleItem(Enums.ResourceType resourceType, WriteInvalidInput valueType, int expectedCode)
        {
            string      fieldAlias = resourceType.ToResourceName() + "." + AppField;
            XmlResource resource   = ResourceHelper.CreateSingleResourceItem(resourceType, fieldAlias, FieldValueMapper.InvalidMapper[valueType], records, true);

            ErrorCode result = ResourceHelper.WriteResourceFail(resource, cleaner);

            Assert.That(result, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 24
0
        public void TestCreateSingleItem(Enums.ResourceType resourceType, string fieldName, Enums.TextType textType, AlphabetLenght characterNumber)
        {
            string      fieldValue = Util.GetRandomText(textType, AlphabetValueMapper.AlphabetMapper[characterNumber]);
            XmlResource resource   = ResourceHelper.CreateSingleResourceItem(resourceType, $"{resourceType.ToResourceName()}.{fieldName}",
                                                                             fieldValue, records, true);
            ErrorCode result = ResourceHelper.WriteResourceFail(resource, cleaner);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 25
0
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, PhaseDateInput phaseDateType, PhaseOptionInput phaseOptionType, int expectedCode, int index)
        {
            phaseDictionary = PhaseFieldHelper.InitPhaseList(phaseSearcher);
            var resource = PhaseFieldHelper.GetUpdatedResourcePhaseField(resourceType, phaseDateType, phaseOptionType, index,
                                                                         phaseSearcher, phaseEntryReader, GetPhaseOrderBySort(resourceType), phaseDictionary, records);
            string result = ResourceHelper.WriteResource(resource, null);

            Assert.That(result, MustBe.EqualTo(records.Data[$"{resourceType.ToPrivateEnum()}{index}"].Id.ToString()), string.Format("Cannot update phase for {0}", resourceType));
        }
Ejemplo n.º 26
0
        private static void ReadOrderPhaseFailed(Dictionary <string, object> urlParameters)
        {
            Handler handler = PublicApiAdapter.CreateAdapterForDefaultConnection().Read(nameof(Phase), urlParameters);

            Assert.That(handler, Is.Not.Null, "Cannot read resource!");
            ErrorCode result = XmlHelper.ParseXMLString <ErrorCode>(handler.RawContent);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE);
        }
        public void TestCreateListItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType)
        {
            string             fieldAlias   = resourceType.ToResourceName() + "." + fieldName;
            List <XmlResource> resourceList = ResourceHelper.CreateListResourceItem(resourceType, fieldAlias, FieldValueMapper.ValidInputMapper[valueType], records, true);

            List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner);

            Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
        public void TestCreateSingleItem(Enums.ResourceType resourceType, InjectionInput fieldType)
        {
            XmlResource resource = ResourceHelper.CreateSingleResourceItem(resourceType, customFields.Data[$"{resourceType}"].Field.ToAlias(),
                                                                           InjectionInputData.InjectionInputMapper[fieldType], records);

            ErrorCode result = ResourceHelper.WriteResourceFail(resource, cleaner);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE);
        }
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, PhaseDateInput phaseDateType, PhaseOptionInput phaseOptionType, int expectedCode)
        {
            phaseDictionary = PhaseFieldHelper.InitPhaseList(phaseSearcher);
            var resource = PhaseFieldHelper.GetUpdatedResourcePhaseField(resourceType, phaseDateType, phaseOptionType, 0,
                                                                         phaseSearcher, phaseEntryReader, GetPhaseOrderBySort(resourceType), phaseDictionary, records);
            ErrorCode result = ResourceHelper.WriteResourceFail(resource, null);

            Assert.That(result, MustBe.MatchingErrorCode(expectedCode), string.Format("Cannot create phase for {0}", resourceType));
        }
Ejemplo n.º 30
0
        public void TestCreateListItem(Enums.ResourceType resourceType, InjectionInput fieldType)
        {
            List <XmlResource> resources = ResourceHelper.CreateListResourceItem(resourceType, $"{resourceType.ToResourceName()}.{AppField}",
                                                                                 InjectionInputData.InjectionInputMapper[fieldType], records);

            ErrorCode result = ResourceHelper.WriteResourcesFail(resources, cleaner);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 31
0
        public void TestReadInjection(string param)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { param, SQLInjection },
            };
            ErrorCode result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadFail <Partition>(parameters);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 32
0
        public void CreateRecordWithDeletedFieldTest(Enums.ResourceType resource)
        {
            var resourceItem = ResourceHelper.CreateResourceInstance(RecordCreator, resource);

            resourceItem.DictionaryValues.Add($"{resource.ToString()}.{DeletedFieldsCreator.Data[resource].Name}", "TEST VALUE");

            var result = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteFail(resourceItem, cleaner.DeleteMany);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.ParameterIsInvalid), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 33
0
        public void TestCreateListItem(Enums.ResourceType resourceType, Enums.TextType textType, AlphabetLenght characterNumber)
        {
            string             fieldValue = Util.GetRandomText(textType, AlphabetValueMapper.AlphabetMapper[characterNumber]);
            List <XmlResource> resources  = ResourceHelper.CreateListResourceItem(resourceType, customFields.Data[$"{resourceType}"].Field.ToAlias(),
                                                                                  fieldValue, records);

            ErrorCode result = ResourceHelper.WriteResourcesFail(resources, cleaner);

            Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE);
        }
Ejemplo n.º 34
0
        public void Assertion_should_be_equal_by_value(MustBe condition1, double value1, double? maxValue1,
            MustBe condition2, double value2, double? maxValue2)
        {
            var expectedValue = condition1 == condition2 
                && value1.Equals(value2) 
                && maxValue1.Equals(maxValue2);

            var assertion1 = new Assertion(condition1, value1, maxValue1);
            var assertion2 = new Assertion(condition2, value2, maxValue2);

            var actualValue = assertion1.Equals(assertion2);
            Assert.Equal(expectedValue, actualValue);
        }
Ejemplo n.º 35
0
 public static string MustBeToString(MustBe condition)
 {
     switch (condition)
     {
         case MustBe.Between:
             return "must be between";
         case MustBe.ExactlyEqualTo:
             return "must be exactly";
         case MustBe.GreaterThan:
             return "must be greater than";
         case MustBe.GreaterThanOrEqualTo:
             return "must be greater than or equal to";
         case MustBe.LessThan:
             return "must be less than";
         case MustBe.LessThanOrEqualTo:
             return "must be less than or equal to";
         default:
             return "(unspecified)";
     }
 }
 public CounterTotalAssertionAttribute(string counterName, MustBe condition, double averageOperationsTotal)
     : base(counterName)
 {
     Condition = condition;
     AverageOperationsTotal = averageOperationsTotal;
 }
 public MemoryAssertionAttribute(MemoryMetric metric, MustBe condition, double averageBytes) : base(metric)
 {
     Condition = condition;
     AverageBytes = averageBytes;
 }
Ejemplo n.º 38
0
    protected int NeighborOf(int pointId, MustBe mustBe)
    {
        var rule = new NeighborhoodRule
        {
            PointId = pointId,
            MustBe = mustBe
        };
        _rules.Add(rule);

        return _rules.Count;
    }
 public PerformanceCounterThroughputAssertionAttribute(string categoryName, string counterName, MustBe condition, double averageValuePerSecond)
     : base(categoryName, counterName)
 {
     Condition = condition;
     AverageValuePerSecond = averageValuePerSecond;
 }
 public CounterThroughputAssertionAttribute(string counterName, MustBe condition, double averageOperationsPerSecond)
     : base(counterName)
 {
     Condition = condition;
     AverageOperationsPerSecond = averageOperationsPerSecond;
 }
 public PerformanceCounterTotalAssertionAttribute(string categoryName, string counterName, MustBe condition, double averageValueTotal)
     : base(categoryName, counterName)
 {
     Condition = condition;
     AverageValueTotal = averageValueTotal;
 }
Ejemplo n.º 42
0
 public GcTotalAssertionAttribute(GcMetric metric, GcGeneration generations, 
     MustBe condition, double averageOperationsTotal) : base(metric, generations)
 {
     Condition = condition;
     AverageOperationsTotal = averageOperationsTotal;
 }