public void DoNotSetOriginToHostServerNameIfAlreadySet() { var messageFactory = new FakeMessageFactory(); var properties = IPGlobalProperties.GetIPGlobalProperties(); var message = messageFactory.Create(new[] { new Header(Header.Origin, "NotThisMachineName", checkReservedNames: false) }, new Object()); var serverName = properties.DomainName.IsNullOrWhiteSpace() ? properties.HostName : $"{properties.HostName}.{properties.DomainName}"; Assert.NotEqual(serverName, message.Headers.GetOrigin()); }
public void SetOriginToHostServerNameIfNotAlreadySet() { var messageFactory = new FakeMessageFactory(); var properties = IPGlobalProperties.GetIPGlobalProperties(); var message = messageFactory.Create(HeaderCollection.Empty, new Object()); var serverName = properties.DomainName.IsNullOrWhiteSpace() ? properties.HostName : $"{properties.HostName}.{properties.DomainName}"; Assert.Equal(serverName, message.Headers.GetOrigin()); }
public void SetTimestampToSystemTimeIfNotAlreadySet() { var now = DateTime.UtcNow; var messageFactory = new FakeMessageFactory(); SystemTime.OverrideWith(() => now); var message = messageFactory.Create(HeaderCollection.Empty, new Object()); Assert.Equal(now.ToString(DateTimeFormat.RFC1123), message.Headers.GetTimestamp().ToString(DateTimeFormat.RFC1123)); }
public void AlwaysSetTimestamp() { var now = DateTime.UtcNow; var messageFactory = new FakeMessageFactory(); var timestamp = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)); SystemTime.OverrideWith(() => now); var message = messageFactory.Create(new[] { new Header(Header.Timestamp, timestamp.ToString(DateTimeFormat.RoundTrip), checkReservedNames: false) }, new Object()); Assert.True(message.Headers.GetTimestamp() > timestamp); }
public void HeadersCanBeNull() { var messageFactory = new FakeMessageFactory(); Assert.NotNull(messageFactory.Create(null, new Object())); }