public void TestGetDataNegativeIndex() { var registry = new SendableRegistry(); var sendableMock = new Mock <ISendable>(); Assert.Throws <ArgumentOutOfRangeException>(() => registry.GetData(sendableMock.Object, -1)); }
public void TestGetDataNonExistant() { var registry = new SendableRegistry(); var sendableMock = new Mock <ISendable>(); Assert.Null(registry.GetData(sendableMock.Object, 0)); }
public void TestSetDataTwiceWorks() { var registry = new SendableRegistry(); var sendableMock = new Mock <ISendable>(); registry.Add(sendableMock.Object, "mysendable"); string data = "42"; Assert.Null(registry.SetData(sendableMock.Object, 0, data)); Assert.Equal(data, registry.GetData(sendableMock.Object, 0)); string data2 = "world"; Assert.Equal(data, registry.SetData(sendableMock.Object, 0, data2)); Assert.Equal(data2, registry.GetData(sendableMock.Object, 0)); }
private static Component GetOrAdd(ISendable sendable) { Component?data = (Component?)registry.GetData(sendable, dataHandle); if (data == null) { data = new Component(); registry.SetData(sendable, dataHandle, data); } return(data); }