コード例 #1
0
        public void Equals_SuppliedObjectIsNull_ResultIsFalse()
        {
            // Arrange
            var object1 = new SystemInformation
                {
                    MachineName = Environment.MachineName,
                    Timestamp = DateTime.UtcNow,
                    SystemPerformance = new SystemPerformanceData()
                };
            SystemInformation object2 = null;

            // Act
            bool result = object1.Equals(object2);

            // Assert
            Assert.IsFalse(result);
        }
コード例 #2
0
        public void Equals_TwoIdenticalInitializedObjects_ResultIsTrue()
        {
            // Arrange
            var timestamp = DateTime.UtcNow;
            var object1 = new SystemInformation
                {
                    MachineName = Environment.MachineName,
                    Timestamp = timestamp,
                    SystemPerformance = new SystemPerformanceData()
                };
            var object2 = new SystemInformation
                {
                    MachineName = Environment.MachineName,
                    Timestamp = timestamp,
                    SystemPerformance = new SystemPerformanceData()
                };

            // Act
            bool result = object1.Equals(object2);

            // Assert
            Assert.IsTrue(result);
        }
コード例 #3
0
        public void Equals_TwoUninitializedObjects_ResultIsTrue()
        {
            // Arrange
            var object1 = new SystemInformation();
            var object2 = new SystemInformation();

            // Act
            bool result = object1.Equals(object2);

            // Assert
            Assert.IsTrue(result);
        }
コード例 #4
0
        public void Equals_TwoIdenticalObjectsWithDifferentCasing_ResultIsTrue()
        {
            // Arrange
            var timestamp = DateTime.UtcNow;
            var object1 = new SystemInformation
                {
                    MachineName = Environment.MachineName.ToLower(),
                    Timestamp = timestamp,
                    SystemPerformance = new SystemPerformanceData()
                };
            var object2 = new SystemInformation
                {
                    MachineName = Environment.MachineName.ToUpper(),
                    Timestamp = timestamp,
                    SystemPerformance = new SystemPerformanceData()
                };

            // Act
            bool result = object1.Equals(object2);

            // Assert
            Assert.IsTrue(result);
        }