public void ReuseMessageBuilderAddTag_Build_CreatesMessageWithTag() { var uut = new MessageBuilder(); var bytes = uut.AddTag(21, "test3").Build(); bytes = uut.AddTag(22, "test").Build(); Assert.True(ConverterTestHelper.GetEncodedMessage("8=FIX.4.4|9=8|22=test|10=050|").SequenceEqual(bytes)); }
public void GivenEncodedTag_Build_CreatesMessageWithTag() { var uut = new MessageBuilder(); var bytes = uut.AddTag(22, "tést", MessageEncoding.UTF8).Build(); Assert.True(ConverterTestHelper.GetEncodedMessage("8=FIX.4.4|9=9|22=", Encoding.UTF8.GetBytes("tést"), "|10=058|").SequenceEqual(bytes)); }
public void GivenTwoAddTag_Build_CreatesMessageWithTag() { var uut = new MessageBuilder(); var bytes = uut.AddTag(22, "test").AddTag(23, "test2").Build(); Assert.True(ConverterTestHelper.GetEncodedMessage("8=FIX.4.4|9=17|22=test|23=test2|10=247|").SequenceEqual(bytes)); }
private Task SendWithOptions(IdentityMessage message) { ThrowIf.IsArgumentNull(() => message); var builder = new MessageBuilder(); builder. SetSubject(message.Subject). AddToRecipient(new Recipient { Email = message.Destination }); //set the default from if (_options.DefaultFrom != null) { builder.SetFromAddress(_options.DefaultFrom); } //override replyTo if it was set by SendAsync if (_from != null) { builder.SetFromAddress(_from); } //do customization based on service options builder.SetClickTracking(_options.TrackingClicks); builder.SetDkim(_options.UseDkim); builder.SetOpenTracking(_options.TrackingOpen); builder.SetTestMode(_options.TestMode); //add body if (_options.UseHtmlBody) { builder.SetHtmlBody(message.Body); } else { builder.SetTextBody(message.Body); } //set the default replyTo if (_options.DefaultReplyTo != null) { builder.SetReplyToAddress(_options.DefaultReplyTo); } //override replyTo if it was set by SendAsync if (_replyTo != null) { builder.SetReplyToAddress(_replyTo); } //add tags and headers if (_options.DefaultHeaders != null && _options.DefaultHeaders.Count > 0) { foreach (var kvp in _options.DefaultHeaders) { builder.AddCustomHeader(kvp.Key, kvp.Value); } } if (_options.DefaultTags != null && _options.DefaultTags.Count > 0) { _options.DefaultTags.ToList().ForEach(t => builder.AddTag(t)); } //send the message return(_messageService.SendMessageAsync(_options.Domain, builder.GetMessage())); }
public void GivenStringNoSOH_Build_ThrowsArgumentException() { var uut = new MessageBuilder(); Assert.Throws <ArgumentException>(() => uut.AddTag("22=test").Build()); }