Esempio n. 1
0
        public void Default_FreeDiscSpaceInPercent_IsSetToZero()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation();

            // Assert
            Assert.AreEqual(0.0d, object1.FreeDiscSpaceInPercent);
        }
Esempio n. 2
0
        public void Default_DeviceName_IsNull()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation();

            // Assert
            Assert.IsNull(object1.DeviceName);
        }
Esempio n. 3
0
        public void Equals_TwoUninitializedObjects_ResultIsTrue()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation();
            var object2 = new SystemStorageDeviceInformation();

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

            // Assert
            Assert.IsTrue(result);
        }
Esempio n. 4
0
        public void ToString_Contains_FreeDiscSpaceInPercent()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 30.0d
            };

            // Act
            string result = object1.ToString();

            // Assert
            Assert.IsTrue(result.Contains(object1.FreeDiscSpaceInPercent.ToString()));
        }
Esempio n. 5
0
        public void GetHashCode_TwoIdenticalObjects_BothUninitialized_HashCodesAreEqual()
        {
            // Arrange
            var package1 = new SystemStorageDeviceInformation();
            var package2 = new SystemStorageDeviceInformation();

            // Act
            int hashCodeObject1 = package1.GetHashCode();
            int hashCodeObject2 = package2.GetHashCode();

            // Assert
            Assert.AreEqual(hashCodeObject1, hashCodeObject2);
        }
Esempio n. 6
0
        public void Equals_SuppliedObjectIsOfOtherType_ResultIsFalse()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 30.0d
            };
            var object2 = new object();

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

            // Assert
            Assert.IsFalse(result);
        }
Esempio n. 7
0
        public void ToString_Contains_AvailableMemoryInGB()
        {
            // Arrange
            var entry1  = new SystemStorageDeviceInformation();
            var object1 = new SystemStorageInformation {
                StorageDeviceInfos = new[] { entry1 }
            };

            // Act
            string result = object1.ToString();

            // Assert
            Assert.IsTrue(result.Contains(entry1.ToString()));
        }
Esempio n. 8
0
        public void Equals_TwoIdenticalInitializedObjects_ResultIsTrue()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 30.0d
            };
            var object2 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 30.0d
            };

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

            // Assert
            Assert.IsTrue(result);
        }
        public void GetStorageUtilizationInPercent_SystemStorageInformationParameterDeviceInfoPropertyIsNotEmpty_ValueIsInverseOfFreeDiscSpaceInPercent()
        {
            // Arrange
            var device1 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 10d
            };
            var systemStorageInformation = new SystemStorageInformation {
                StorageDeviceInfos = new[] { device1 }
            };
            var storageStatusOrchestrator = new StorageStatusOrchestrator();

            // Act
            var result = storageStatusOrchestrator.GetStorageUtilizationInPercent(systemStorageInformation);

            // Assert
            Assert.AreEqual(100d - device1.FreeDiscSpaceInPercent, result.First().Value);
        }
        public void GetStorageUtilizationInPercent_SystemStorageInformationParameterDeviceInfoPropertyIsNotEmpty_NameContainsDeviceName()
        {
            // Arrange
            var device1 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 10d
            };
            var systemStorageInformation = new SystemStorageInformation {
                StorageDeviceInfos = new[] { device1 }
            };
            var storageStatusOrchestrator = new StorageStatusOrchestrator();

            // Act
            var result = storageStatusOrchestrator.GetStorageUtilizationInPercent(systemStorageInformation);

            // Assert
            Assert.IsTrue(result.First().Name.Contains(device1.DeviceName));
        }
Esempio n. 11
0
        public void GetHashCode_TwoDistinctObjects_HashCodesAreDifferent()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 30.0d
            };
            var object2 = new SystemStorageDeviceInformation {
                DeviceName = "E:", FreeDiscSpaceInPercent = 10.0d
            };

            // Act
            int hashCodeObject1 = object1.GetHashCode();
            int hashCodeObject2 = object2.GetHashCode();

            // Assert
            Assert.AreNotEqual(hashCodeObject1, hashCodeObject2);
        }
Esempio n. 12
0
        public void GetHashCode_TwoIdenticalObjects_BothInitialized_HashCodesAreEqual()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 30.0d
            };
            var object2 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 30.0d
            };

            // Act
            int hashCodeObject1 = object1.GetHashCode();
            int hashCodeObject2 = object2.GetHashCode();

            // Assert
            Assert.AreEqual(hashCodeObject1, hashCodeObject2);
        }
Esempio n. 13
0
        public void GetHashCode_ForAllUniqueObject_AUniqueHashCodeIsReturned()
        {
            var hashCodes = new Dictionary <int, SystemStorageDeviceInformation>();

            for (var i = 0; i < 1000; i++)
            {
                // Act
                var object1 = new SystemStorageDeviceInformation {
                    DeviceName = i.ToString(), FreeDiscSpaceInPercent = i
                };

                int generatedHashCode = object1.GetHashCode();

                // Assert
                Assert.IsFalse(hashCodes.ContainsKey(generatedHashCode));
                hashCodes.Add(generatedHashCode, object1);
            }
        }
Esempio n. 14
0
        public void GetHashCode_SameHashCodeIsReturnedEveryTimeTheMethodIsCalled_AsLongAsTheObjectDoesNotChange()
        {
            // Arrange
            var deviceName             = "C:";
            var freeDiscSpaceInPercent = 30.0d;
            var object1 = new SystemStorageDeviceInformation {
                DeviceName = deviceName, FreeDiscSpaceInPercent = freeDiscSpaceInPercent
            };

            int expectedHashcode = object1.GetHashCode();

            for (var i = 0; i < 100; i++)
            {
                // Act
                object1.DeviceName             = deviceName;
                object1.FreeDiscSpaceInPercent = freeDiscSpaceInPercent;
                int generatedHashCode = object1.GetHashCode();

                // Assert
                Assert.AreEqual(expectedHashcode, generatedHashCode);
            }
        }
        public void GetSystemStatusViewModel_StorageStatusIsNotNull_ResultContainsStorageStatusDataPoint()
        {
            // Arrage
            var deviceInfo1 = new SystemStorageDeviceInformation {
                DeviceName = "C:", FreeDiscSpaceInPercent = 20d
            };
            var deviceInfos   = new[] { deviceInfo1 };
            var storageStatus = new SystemStorageInformation {
                StorageDeviceInfos = deviceInfos
            };
            var systemPerformanceInformation = new SystemPerformanceData {
                StorageStatus = storageStatus
            };
            var systemInformation = new SystemInformation {
                SystemPerformance = systemPerformanceInformation
            };
            var storageStatusViewModel = new SystemStatusPointViewModel {
                Name = "Storage Status" + deviceInfo1.DeviceName, Value = deviceInfo1.FreeDiscSpaceInPercent
            };

            var processorStatusOrchestrator = new Mock <IProcessorStatusOrchestrator>();
            var memoryStatusOrchestrator    = new Mock <IMemoryStatusOrchestrator>();
            var storageStatusOrchestrator   = new Mock <IStorageStatusOrchestrator>();

            storageStatusOrchestrator.Setup(s => s.GetStorageUtilizationInPercent(It.IsAny <SystemStorageInformation>())).Returns(
                new[] { storageStatusViewModel });

            var systemStatusOrchestrator = new SystemStatusOrchestrator(
                processorStatusOrchestrator.Object, memoryStatusOrchestrator.Object, storageStatusOrchestrator.Object);

            // Act
            var result = systemStatusOrchestrator.GetSystemStatusViewModel(systemInformation);

            // Assert
            Assert.AreEqual(storageStatusViewModel.Value, result.DataPoints.First(d => d.Name.Equals(storageStatusViewModel.Name)).Value);
        }