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); }
private Dictionary <string, object> GetUrlParameter(ReadSpecialInvalidInput inputType) { switch (inputType) { case ReadSpecialInvalidInput.CountEquals0: return(new Dictionary <string, object>() { [PartitionApiFields.Count] = 0 }); case ReadSpecialInvalidInput.CountOver200: return(new Dictionary <string, object>() { [PartitionApiFields.Count] = 201 }); case ReadSpecialInvalidInput.MissingRequestType: return(new Dictionary <string, object>()); case ReadSpecialInvalidInput.StartEqualsTotal: Dictionary <string, object> urlParameters1 = new Dictionary <string, object>(); ReadResponseData <Partition> result1 = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Partition>(urlParameters1); Assume.That(result1, MustBe.Not.Null, "Cannot read the total number of Partition!"); return(new Dictionary <string, object>() { [PartitionApiFields.Start] = result1.Total }); case ReadSpecialInvalidInput.StartGreaterThanTotal: Dictionary <string, object> urlParameters2 = new Dictionary <string, object>(); ReadResponseData <Partition> result2 = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Partition>(urlParameters2); Assume.That(result2, MustBe.Not.Null, "Cannot read the total number of Partition!"); return(new Dictionary <string, object>() { [PartitionApiFields.Start] = result2.Total + 1 }); } return(null); }
private Dictionary <string, object> GetUrlParameter(ReadSpecialInvalidInput inputType) { Dictionary <string, object> result = new Dictionary <string, object>() { [FieldApiFields.Partition] = AuthenticationInfoProvider.Current.DefaultPartition, [FieldApiFields.Resource] = (int)Enums.ResourceType.Client, }; switch (inputType) { case ReadSpecialInvalidInput.ActiveEquals2: result[FieldApiFields.Active] = 2; break; case ReadSpecialInvalidInput.ActiveEqualsNegative2: result[FieldApiFields.Active] = -2; break; case ReadSpecialInvalidInput.CountEquals0: result[FieldApiFields.Count] = 0; break; case ReadSpecialInvalidInput.CountOver200: result[FieldApiFields.Count] = 201; break; case ReadSpecialInvalidInput.MissingPartition: result.Remove(FieldApiFields.Partition); break; case ReadSpecialInvalidInput.MissingResource: result.Remove(FieldApiFields.Resource); break; case ReadSpecialInvalidInput.ResourceName: result[FieldApiFields.Resource] = Enums.ResourceType.Client.ToLowerString(); break; case ReadSpecialInvalidInput.StartEqualsTotal: Dictionary <string, object> urlParameters1 = new Dictionary <string, object>() { [FieldApiFields.Partition] = AuthenticationInfoProvider.Current.DefaultPartition, [FieldApiFields.Resource] = (int)Enums.ResourceType.Client, }; ReadResponseData <Field> result1 = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Field>(urlParameters1); Assume.That(result1, MustBe.Not.Null, "The response data is null or cannot be parsed to ReadResponseData!"); result[FieldApiFields.Start] = result1.Total; break; case ReadSpecialInvalidInput.StartGreaterThanTotal: Dictionary <string, object> urlParameters2 = new Dictionary <string, object>() { [FieldApiFields.Partition] = AuthenticationInfoProvider.Current.DefaultPartition, [FieldApiFields.Resource] = (int)Enums.ResourceType.Client, }; ReadResponseData <Field> result2 = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Field>(urlParameters2); Assume.That(result2, MustBe.Not.Null, "The response data is null or cannot be parsed to ReadResponseData"); result[FieldApiFields.Start] = result2.Total + 1; break; } return(result); }
private Dictionary <string, object> GetUrlParameters(ReadSpecialInvalidInput inputType) { Dictionary <string, object> result = new Dictionary <string, object>() { [PhaseApiFields.Partition] = AuthenticationInfoProvider.Current.DefaultPartition, [PhaseApiFields.Resource] = (int)defaultResource, }; long numberNotExist = 9000554554; string phaseId = PhaseHelper.CreatePhase(defaultResource, records.Data[defaultResource.ToPrivateEnum() + "0"].Id.ToString()); switch (inputType) { case ReadSpecialInvalidInput.CountEquals0: result[PhaseApiFields.Count] = 0; break; case ReadSpecialInvalidInput.CountOver200: result[PhaseApiFields.Count] = 201; break; case ReadSpecialInvalidInput.MissingPartition: result.Remove(PhaseApiFields.Partition); break; case ReadSpecialInvalidInput.MissingResource: result.Remove(PhaseApiFields.Resource); break; case ReadSpecialInvalidInput.ResourceName: result[PhaseApiFields.Resource] = defaultResource.ToLowerString(); break; case ReadSpecialInvalidInput.StartEqualsTotal: result[PhaseApiFields.Start] = total; break; case ReadSpecialInvalidInput.StartGreaterThanTotal: result[PhaseApiFields.Start] = total + 1; break; case ReadSpecialInvalidInput.ResourceIdNotExist: result[PhaseApiFields.ResourceId] = numberNotExist; break; case ReadSpecialInvalidInput.ResourceIdFromAnotherResource: result[PhaseApiFields.ResourceId] = records.Data[Enums.ResourceType.Resume.ToPrivateEnum() + "0"].Id; break; case ReadSpecialInvalidInput.ResourceIdValidNumberInHex: result[PhaseApiFields.ResourceId] = "0x" + records.Data[defaultResource.ToPrivateEnum() + "0"].Id.ToString("X"); break; case ReadSpecialInvalidInput.ResourceIdInvalidNumberInHex: result[PhaseApiFields.ResourceId] = "0x" + numberNotExist.ToString("X"); break; case ReadSpecialInvalidInput.ResourceIdValidNumberInE: result[PhaseApiFields.ResourceId] = Util.ToExponential(records.Data[defaultResource.ToPrivateEnum() + "0"].Id.ToString()); break; case ReadSpecialInvalidInput.ResourceIdInvalidNumberInE: result[PhaseApiFields.ResourceId] = Util.ToExponential(numberNotExist.ToString()); break; case ReadSpecialInvalidInput.IdNotExist: result[PhaseApiFields.Id] = numberNotExist; break; case ReadSpecialInvalidInput.IdValidNumberInHex: result[PhaseApiFields.Id] = "0x" + int.Parse(phaseId).ToString("X"); break; case ReadSpecialInvalidInput.IdInvalidNumberInHex: result[PhaseApiFields.Id] = "0x" + numberNotExist.ToString("X"); break; case ReadSpecialInvalidInput.IdValidNumberInE: result[PhaseApiFields.Id] = Util.ToExponential(phaseId); break; case ReadSpecialInvalidInput.IdInvalidNumberInE: result[PhaseApiFields.Id] = Util.ToExponential(numberNotExist.ToString()); break; } return(result); }