Beispiel #1
0
 public override string ToString()
 {
     if (String.IsNullOrWhiteSpace(ClientIdentifier.Server))
     {
         return(Name);
     }
     return(String.Format(CultureInfo.InvariantCulture, "{0} ({1})", Name, ClientIdentifier.ToServerPortString()));
 }
Beispiel #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Ordinal;
         hashCode = (hashCode * 397) ^ ClientIdentifier.GetHashCode();
         hashCode = (hashCode * 397) ^ SlotID;
         return(hashCode);
     }
 }
Beispiel #3
0
        public void ClientIdentifier_AreNotEqualWhenNameServerPortAreNotEqualWithNoGuid()
        {
            // Arrange
            var x = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, Guid.Empty);
            var y = new ClientIdentifier("Fizz", "Bizz", 46330, Guid.Empty);
            // Act
            var result = x.Equals(y) | x.GetHashCode() == y.GetHashCode();

            // Assert
            Assert.IsFalse(result);
        }
Beispiel #4
0
        public void ClientIdentifier_AreNotEqualWhenGuidsAreNotEqual()
        {
            // Arrange
            var x = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, Guid.NewGuid());
            var y = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, Guid.NewGuid());
            // Act
            var result = x.Equals(y) | x.GetHashCode() == y.GetHashCode();

            // Assert
            Assert.IsFalse(result);
        }
Beispiel #5
0
        public void ClientIdentifier_CompareTo_WithoutGuidIsGreaterThanWithGuid()
        {
            // Arrange
            var x = new ClientIdentifier(null, null, ClientSettings.NoPort, Guid.NewGuid());
            var y = new ClientIdentifier(null, null, ClientSettings.NoPort, Guid.Empty);
            // Act
            var result = y.CompareTo(x);

            // Assert
            Assert.AreEqual(1, result);
        }
Beispiel #6
0
        public void ClientIdentifier_AreNotEqualWhenSecondHasGuid()
        {
            // Arrange
            var x = new ClientIdentifier(null, null, ClientSettings.NoPort, Guid.Empty);
            var y = new ClientIdentifier(null, null, ClientSettings.NoPort, Guid.NewGuid());
            // Act
            var result = x.Equals(y) | x.GetHashCode() == y.GetHashCode();

            // Assert
            Assert.IsFalse(result);
        }
Beispiel #7
0
        public void ClientIdentifier_ProteinBenchmarkEqualityComparer_AreNotEqualWhenNameServerPortAreNotEqualWithNoGuid()
        {
            // Arrange
            var x        = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, Guid.Empty);
            var y        = new ClientIdentifier("Fizz", "Bizz", 46330, Guid.Empty);
            var comparer = ClientIdentifier.ProteinBenchmarkEqualityComparer;
            // Act
            var result = comparer.Equals(x, y) | comparer.GetHashCode(x) == comparer.GetHashCode(y);

            // Assert
            Assert.IsFalse(result);
        }
Beispiel #8
0
        public void ClientIdentifier_ProteinBenchmarkEqualityComparer_AreEqualWhenSecondHasGuid()
        {
            // Arrange
            var x        = new ClientIdentifier(null, null, ClientSettings.NoPort, Guid.Empty);
            var y        = new ClientIdentifier(null, null, ClientSettings.NoPort, Guid.NewGuid());
            var comparer = ClientIdentifier.ProteinBenchmarkEqualityComparer;
            // Act
            var result = comparer.Equals(x, y) & comparer.GetHashCode(x) == comparer.GetHashCode(y);

            // Assert
            Assert.IsTrue(result);
        }
Beispiel #9
0
        public void ClientIdentifier_AreEqualWhenGuidsAreEqual()
        {
            // Arrange
            var guid = Guid.NewGuid();
            var x    = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, guid);
            var y    = new ClientIdentifier("Fizz", "Bizz", 46330, guid);
            // Act
            var result = x.Equals(y) & x.GetHashCode() == y.GetHashCode();

            // Assert
            Assert.IsTrue(result);
        }
Beispiel #10
0
        public void ClientIdentifier_FromPath_ServerColonPort()
        {
            const string path = "Server:12345";
            // Act
            var identifier = ClientIdentifier.FromPath("Foo", path, Guid.Empty);

            // Assert
            Assert.AreEqual("Foo", identifier.Name);
            Assert.AreEqual("Server", identifier.Server);
            Assert.AreEqual(12345, identifier.Port);
            Assert.AreEqual(Guid.Empty, identifier.Guid);
        }
Beispiel #11
0
        public void ClientIdentifier_ProteinBenchmarkEqualityComparer_AreEqualWhenGuidsAreNotEqual()
        {
            // Arrange
            var x        = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, Guid.NewGuid());
            var y        = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, Guid.NewGuid());
            var comparer = ClientIdentifier.ProteinBenchmarkEqualityComparer;
            // Act
            var result = comparer.Equals(x, y) & comparer.GetHashCode(x) == comparer.GetHashCode(y);

            // Assert
            Assert.IsTrue(result);
        }
Beispiel #12
0
        public void ClientIdentifier_CompareTo_ReturnsNonZeroWhenGuidsAreNotEqual()
        {
            // Arrange
            var x = new ClientIdentifier(null, null, ClientSettings.NoPort, Guid.NewGuid());
            var y = new ClientIdentifier(null, null, ClientSettings.NoPort, Guid.NewGuid());
            // Act
            var result = x.CompareTo(y);

            // Assert
            Assert.AreNotEqual(0, result);
            Assert.IsFalse(x == y);
            Assert.IsTrue(x != y);
        }
Beispiel #13
0
        public void ClientIdentifier_CompareTo_ReturnsNonZeroWhenNameServerAndPortAreNotEqual()
        {
            // Arrange
            var x = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, Guid.Empty);
            var y = new ClientIdentifier("Fizz", "Bizz", 46330, Guid.Empty);
            // Act
            var result = x.CompareTo(y);

            // Assert
            Assert.AreNotEqual(0, result);
            Assert.IsFalse(x == y);
            Assert.IsTrue(x != y);
        }
Beispiel #14
0
        public void ClientIdentifier_FromPath_FileSystemPath()
        {
            const string path = @"\\server\share";
            var          guid = Guid.NewGuid();
            // Act
            var identifier = ClientIdentifier.FromPath("Bar", path, guid);

            // Assert
            Assert.AreEqual("Bar", identifier.Name);
            Assert.AreEqual(path, identifier.Server);
            Assert.AreEqual(ClientSettings.NoPort, identifier.Port);
            Assert.AreEqual(guid, identifier.Guid);
        }
Beispiel #15
0
        public int CompareTo(SlotIdentifier other)
        {
            var ordinalComparison = Ordinal.CompareTo(other.Ordinal);

            if (ordinalComparison != 0)
            {
                return(ordinalComparison);
            }
            var clientComparison = ClientIdentifier.CompareTo(other.ClientIdentifier);

            if (clientComparison != 0)
            {
                return(clientComparison);
            }
            return(SlotID.CompareTo(other.SlotID));
        }
Beispiel #16
0
        public void ClientIdentifier_ToServerAndPortString_WithServer()
        {
            var identifier = new ClientIdentifier("Foo", "Bar", ClientSettings.NoPort, Guid.Empty);

            Assert.AreEqual("Bar", identifier.ToServerPortString());
        }
Beispiel #17
0
 public bool Equals(SlotIdentifier other)
 {
     return(Ordinal == other.Ordinal && ClientIdentifier.Equals(other.ClientIdentifier) && SlotID == other.SlotID);
 }
Beispiel #18
0
 public SlotIdentifier(ClientIdentifier clientIdentifier, int slotID)
 {
     Ordinal          = Int32.MaxValue;
     ClientIdentifier = clientIdentifier;
     SlotID           = slotID;
 }
Beispiel #19
0
 private SlotIdentifier(int ordinal, string name)
 {
     Ordinal          = ordinal;
     ClientIdentifier = new ClientIdentifier(name, null, ClientSettings.NoPort, Guid.Empty);
     SlotID           = NoSlotID;
 }
Beispiel #20
0
        public void ClientIdentifier_ToString_WithServerAndPort()
        {
            var identifier = new ClientIdentifier("Foo", "Bar", ClientSettings.DefaultPort, Guid.Empty);

            Assert.AreEqual($"Foo (Bar:{ClientSettings.DefaultPort})", identifier.ToString());
        }
Beispiel #21
0
        public void ClientIdentifier_ToString_WithOnlyName()
        {
            var identifier = new ClientIdentifier("Foo", null, ClientSettings.NoPort, Guid.Empty);

            Assert.AreEqual("Foo", identifier.ToString());
        }