public void BuildForwardsKeyValueDefaultsToInstance() { // given var defaults = ResponseAttributesDefaults.JsonResponse; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.Build(); // then Assert.That(obtained.MaxBeaconSizeInBytes, Is.EqualTo(defaults.MaxBeaconSizeInBytes)); Assert.That(obtained.MaxSessionDurationInMilliseconds, Is.EqualTo(defaults.MaxSessionDurationInMilliseconds)); Assert.That(obtained.MaxEventsPerSession, Is.EqualTo(defaults.MaxEventsPerSession)); Assert.That(obtained.SessionTimeoutInMilliseconds, Is.EqualTo(defaults.SessionTimeoutInMilliseconds)); Assert.That(obtained.SendIntervalInMilliseconds, Is.EqualTo(defaults.SendIntervalInMilliseconds)); Assert.That(obtained.VisitStoreVersion, Is.EqualTo(defaults.VisitStoreVersion)); Assert.That(obtained.IsCapture, Is.EqualTo(defaults.IsCapture)); Assert.That(obtained.IsCaptureCrashes, Is.EqualTo(defaults.IsCaptureCrashes)); Assert.That(obtained.IsCaptureErrors, Is.EqualTo(defaults.IsCaptureErrors)); Assert.That(obtained.ApplicationId, Is.EqualTo(defaults.ApplicationId)); Assert.That(obtained.Multiplicity, Is.EqualTo(defaults.Multiplicity)); Assert.That(obtained.ServerId, Is.EqualTo(defaults.ServerId)); Assert.That(obtained.Status, Is.EqualTo(defaults.Status)); Assert.That(obtained.TimestampInMilliseconds, Is.EqualTo(defaults.TimestampInMilliseconds)); }
public void BuildWithKeyValueDefaultsHasNoAttributeSetOnInstance() { // given var target = ResponseAttributes.WithKeyValueDefaults().Build(); // when, then foreach (var attribute in Enum.GetValues(typeof(ResponseAttribute)).Cast <ResponseAttribute>()) { Assert.That(target.IsAttributeSet(attribute), Is.False); } }
public void IsErroneousResponseGivesFalseIfStatusResponseAttributeIsNotSet() { // given var attributes = ResponseAttributes.WithUndefinedDefaults().Build(); var target = StatusResponse.CreateSuccessResponse( logger, attributes, StatusResponse.HttpOk, new Dictionary <string, List <string> >()); // when, then Assert.That(target.IsErroneousResponse, Is.False); }
public void BuildPropagatesServerIdToInstance() { // given const int serverId = 73; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithServerId(serverId).Build(); // then Assert.That(obtained.ServerId, Is.EqualTo(serverId)); }
public void BuildPropagatesMaxBeaconSizeToInstance() { // given const int beaconSize = 73; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithMaxBeaconSizeInBytes(beaconSize).Build(); // then Assert.That(obtained.MaxBeaconSizeInBytes, Is.EqualTo(beaconSize)); }
public void BuildPropagatesStatusToInstance() { // given const string status = "status"; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithStatus(status).Build(); // then Assert.That(obtained.Status, Is.EqualTo(status)); }
public void BuildPropagatesApplicationIdToInstance() { // given var applicationId = Guid.NewGuid().ToString(); var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithApplicationId(applicationId).Build(); // then Assert.That(obtained.ApplicationId, Is.EqualTo(applicationId)); }
public void BuildPropagatesMultiplicityToInstance() { // given const int multiplicity = 73; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithMultiplicity(multiplicity).Build(); // then Assert.That(obtained.Multiplicity, Is.EqualTo(multiplicity)); }
public void BuildPropagatesSendIntervalToInstance() { // given const int sendInterval = 73; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithSendIntervalInMilliseconds(sendInterval).Build(); // then Assert.That(obtained.SendIntervalInMilliseconds, Is.EqualTo(sendInterval)); }
public void BuildPropagatesIsCaptureErrorsToInstance() { // given var isCaptureErrors = !ResponseAttributesDefaults.JsonResponse.IsCaptureErrors; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithCaptureErrors(isCaptureErrors).Build(); // then Assert.That(obtained.IsCaptureErrors, Is.EqualTo(isCaptureErrors)); }
public void BuildPropagatesVisitStoreVersionToInstance() { // given const int visitStoreVersion = 73; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithVisitStoreVersion(visitStoreVersion).Build(); // then Assert.That(obtained.VisitStoreVersion, Is.EqualTo(visitStoreVersion)); }
public void BuildPropagatesMaxEventsPerSessionToInstance() { // given const int eventsPerSession = 73; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithMaxEventsPerSession(eventsPerSession).Build(); // then Assert.That(obtained.MaxEventsPerSession, Is.EqualTo(eventsPerSession)); }
public void BuildPropagatesMaxSessionDurationToInstance() { // given const int sessionDuration = 73; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithMaxSessionDurationInMilliseconds(sessionDuration).Build(); // then Assert.That(obtained.MaxSessionDurationInMilliseconds, Is.EqualTo(sessionDuration)); }
public void BuildPropagatesTimestampToInstance() { // given const long timestamp = 73; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithTimestampInMilliseconds(timestamp).Build(); // then Assert.That(obtained.TimestampInMilliseconds, Is.EqualTo(timestamp)); }
public void MergeTakesMultiplicityFromMergeSourceIfSetInSourceAndTarget() { // given const int multiplicity = 73; var source = ResponseAttributes.WithUndefinedDefaults().WithMultiplicity(multiplicity).Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithMultiplicity(37).Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.Multiplicity, Is.EqualTo(multiplicity)); }
public void MergeTakesTimestampFromMergeSourceIfSetInSourceAndTarget() { // given const long timestamp = 73; var source = ResponseAttributes.WithUndefinedDefaults().WithTimestampInMilliseconds(timestamp).Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithTimestampInMilliseconds(37).Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.TimestampInMilliseconds, Is.EqualTo(timestamp)); }
public void MergeTakesStatusFromMergeSourceIfSetInSourceAndTarget() { // given const string status = "status"; var source = ResponseAttributes.WithUndefinedDefaults().WithStatus(status).Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithStatus("foobar").Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.Status, Is.EqualTo(status)); }
public void MergeTakesServerIdFromMergeSourceIfSetInSourceAndTarget() { // given const int serverId = 73; var source = ResponseAttributes.WithUndefinedDefaults().WithServerId(serverId).Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithServerId(37).Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.ServerId, Is.EqualTo(serverId)); }
public void MergeTakesCaptureFromMergeSourceIfSetInSource() { // given var capture = !ResponseAttributesDefaults.Undefined.IsCapture; var source = ResponseAttributes.WithUndefinedDefaults().WithCapture(capture).Build(); var target = ResponseAttributes.WithUndefinedDefaults().Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.IsCapture, Is.EqualTo(capture)); }
public void MergeTakesApplicationIdFromMergeSourceIfSetInSourceAndTarget() { // given var applicationId = Guid.NewGuid().ToString(); var source = ResponseAttributes.WithUndefinedDefaults().WithApplicationId(applicationId).Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithApplicationId(Guid.NewGuid().ToString()).Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.ApplicationId, Is.EqualTo(applicationId)); }
public void MergeTakesVisitStoreVersionFromMergeSourceIfSetInSourceAndTarget() { // given const int visitStoreVersion = 73; var source = ResponseAttributes.WithUndefinedDefaults().WithVisitStoreVersion(visitStoreVersion).Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithVisitStoreVersion(37).Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.VisitStoreVersion, Is.EqualTo(visitStoreVersion)); }
public void MergeTakesEventsPerSessionFromMergeTargetIfNotSetInSource() { // given const int eventsPerSession = 73; var source = ResponseAttributes.WithUndefinedDefaults().Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithMaxEventsPerSession(eventsPerSession).Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.MaxEventsPerSession, Is.EqualTo(eventsPerSession)); }
public void MergeTakesBeaconSizeFromMergeSourceIfSetInSourceAndTarget() { // given const int beaconSize = 73; var source = ResponseAttributes.WithUndefinedDefaults().WithMaxBeaconSizeInBytes(beaconSize).Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithMaxBeaconSizeInBytes(37).Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.MaxBeaconSizeInBytes, Is.EqualTo(beaconSize)); }
public void MergeTakesSendIntervalFromMergeSourceIfSetInSource() { // given const int sendInterval = 73; var source = ResponseAttributes.WithUndefinedDefaults().WithSendIntervalInMilliseconds(sendInterval) .Build(); var target = ResponseAttributes.WithUndefinedDefaults().Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.SendIntervalInMilliseconds, Is.EqualTo(sendInterval)); }
public void MergeTakesSessionTimeoutFromMergeSourceIfSetInSourceAndTarget() { // given const int sessionTimeout = 73; var source = ResponseAttributes.WithUndefinedDefaults().WithSessionTimeoutInMilliseconds(sessionTimeout) .Build(); var target = ResponseAttributes.WithUndefinedDefaults().WithSessionTimeoutInMilliseconds(37).Build(); // when var obtained = target.Merge(source); // then Assert.That(obtained, Is.Not.Null); Assert.That(obtained.SessionTimeoutInMilliseconds, Is.EqualTo(sessionTimeout)); }
public void MergingDefaultResponsesReturnsResponseWithoutAnyAttributeSet() { // given var toMerge = ResponseAttributes.WithUndefinedDefaults().Build(); var target = ResponseAttributes.WithJsonDefaults().Build(); // when var obtained = target.Merge(toMerge); // then foreach (var attribute in Enum.GetValues(typeof(ResponseAttribute)).Cast <ResponseAttribute>()) { Assert.That(obtained.IsAttributeSet(attribute), Is.False); } }
public static IResponseAttributes Parse(string keyValuePairResponse) { var keyValuePairs = ParseKeyValuePairs(keyValuePairResponse); var builder = ResponseAttributes.WithKeyValueDefaults(); ApplyBeaconSizeInKb(builder, keyValuePairs); ApplySendIntervalInSec(builder, keyValuePairs); ApplyCapture(builder, keyValuePairs); ApplyReportCrashes(builder, keyValuePairs); ApplyReportErrors(builder, keyValuePairs); ApplyServerId(builder, keyValuePairs); ApplyMultiplicity(builder, keyValuePairs); return(builder.Build()); }
public static IResponseAttributes Parse(string jsonResponse) { var parser = new JsonParser(jsonResponse); var parsedValue = parser.Parse(); var rootObject = (JsonObjectValue)parsedValue; var builder = ResponseAttributes.WithJsonDefaults(); ApplyAgentConfiguration(builder, rootObject); ApplyApplicationConfiguration(builder, rootObject); ApplyDynamicConfiguration(builder, rootObject); ApplyRootAttributes(builder, rootObject); return(builder.Build()); }
public void MergeResponseWithAllValuesSetToDefaultResponse() { // given var toMerge = Substitute.For <IResponseAttributes>(); toMerge.IsAttributeSet(Arg.Any <ResponseAttribute>()).Returns(true); var target = ResponseAttributes.WithUndefinedDefaults().Build(); // when var obtained = target.Merge(toMerge); // then foreach (var attribute in Enum.GetValues(typeof(ResponseAttribute)).Cast <ResponseAttribute>()) { Assert.That(obtained.IsAttributeSet(attribute), Is.True); } }
public void WithTimestampSetsAttributeOnInstance() { // given const ResponseAttribute attribute = ResponseAttribute.TIMESTAMP; var target = ResponseAttributes.WithJsonDefaults(); // when var obtained = target.WithTimestampInMilliseconds(37L).Build(); // then Assert.That(obtained.IsAttributeSet(attribute), Is.True); foreach (var unsetAttribute in Enum.GetValues(typeof(ResponseAttribute)).Cast <ResponseAttribute>()) { if (attribute == unsetAttribute) { continue; } Assert.That(obtained.IsAttributeSet(unsetAttribute), Is.False); } }