public void MemberInfoTest() { var memberId = Guid.NewGuid(); var address = NetworkAddress.Parse("192.168.33.34:5569"); var version = new MemberVersion(4, 5, 6); var attributes = new Dictionary <string, string> { { "attribute", "value" } }; var x = new MemberInfo(memberId, address, version, true, attributes); Console.WriteLine(x); Assert.That(x.Id, Is.EqualTo(memberId)); Assert.That(x.Uuid, Is.EqualTo(memberId)); Assert.That(x.Address, Is.SameAs(address)); Assert.That(x.Version, Is.SameAs(version)); Assert.That(x.IsLite, Is.True); Assert.That(x.IsLiteMember, Is.True); var a = x.Attributes; Assert.That(a.Count, Is.EqualTo(1)); Assert.That(a["attribute"], Is.EqualTo("value")); Assert.That(x, Resolves.Equatable( // weird indeed, but only the ID matters new MemberInfo(memberId, x.Address, x.Version, x.IsLite, attributes), new MemberInfo(Guid.NewGuid(), x.Address, x.Version, x.IsLite, attributes) )); }
internal Func <T> GetResolve <T>(Func <T> defaultFactory) { //try from root first! if (RootServiceProvider != null) { var theService = RootServiceProvider.GetService <T>(); if (theService != null) { return(() => theService); } } if (defaultFactory == null) { throw new ArgumentNullException(nameof(defaultFactory)); } Resolves.TryGetValue(typeof(T), out var result); if (result != null) { return((Func <T>)result); } Func <T> theFunc = () => LazyValueFactory <T> .Default.GetResolve(defaultFactory).Value; Resolves[typeof(T)] = theFunc; return(theFunc); }
public void DistributedObjectInfoTest() { var x = new DistributedObjectInfo("serviceName", "name"); Console.WriteLine(x); Assert.That(x.ServiceName, Is.EqualTo("serviceName")); Assert.That(x.Name, Is.EqualTo("name")); Assert.That(x, Resolves.Equatable( new DistributedObjectInfo("serviceName", "name"), new DistributedObjectInfo("serviceName", "other"), new DistributedObjectInfo("other", "other"))); }