public void UpdateMetadata_should_update_metadata_and_last_modified_time() { var endpoint = new Endpoint(_timeCoordinator.Object, new EndpointIdentity(Guid.NewGuid(), "monitor", "address"), new EndpointMetadata("name", "group", new[] { "t1" }, EndpointMetadata.DefaultMonitorTag, DateTime.UtcNow, DateTime.UtcNow)); var expectedLastModifiedTime = DateTime.UtcNow; _timeCoordinator.Setup(c => c.UtcNow).Returns(expectedLastModifiedTime); endpoint.UpdateMetadata("new group", "new name", new[] { "t1", "t2" }, EndpointMetadata.DefaultMonitorTag); Assert.Equal("new group", endpoint.Metadata.Group); Assert.Equal("new name", endpoint.Metadata.Name); Assert.Equal(new[] { "t1", "t2" }, endpoint.Metadata.Tags); Assert.Equal(expectedLastModifiedTime, endpoint.LastModifiedTimeUtc); }
public void UpdateMetadata_should_update_monitorTag_only_if_new_value_is_not_null() { var initalMonitorTag = "initial"; var newMonitorTag = "newValue"; var endpoint = new Endpoint(_timeCoordinator.Object, new EndpointIdentity(Guid.NewGuid(), "monitor", "address"), new EndpointMetadata("name", "group", null, initalMonitorTag, DateTime.UtcNow, DateTime.UtcNow)); Assert.Equal(initalMonitorTag, endpoint.Metadata.MonitorTag); endpoint.UpdateMetadata("new group", "new name", null, newMonitorTag); Assert.Equal(newMonitorTag, endpoint.Metadata.MonitorTag); }
public void UpdateMetadata_should_not_allow_null_monitorTag() { var endpoint = new Endpoint(_timeCoordinator.Object, new EndpointIdentity(Guid.NewGuid(), "monitor", "address"), new EndpointMetadata("name", "group", null, "initial", DateTime.UtcNow, DateTime.UtcNow)); var ex = Assert.Throws<ArgumentException>(() => endpoint.UpdateMetadata("new group", "new name", new[] { "t1" }, null)); Assert.Equal("MonitorTag cannot be null or empty", ex.Message); }