public void Default_FreeDiscSpaceInPercent_IsSetToZero()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation();

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

            // Assert
            Assert.IsNull(object1.DeviceName);
        }
        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 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);
        }
        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));
        }
        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);
        }
        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()));
        }
        public void GetHashCode_SameHashCodeIsReturnedEveryTimeTheMethodIsCalled_AsLongAsTheObjectDoesNotChange()
        {
            // Arrange
            var device1 = new SystemStorageDeviceInformation { DeviceName = "C:", FreeDiscSpaceInPercent = 50.0d };
            var object1 = new SystemStorageInformation { StorageDeviceInfos = new[] { device1 } };

            int expectedHashcode = object1.GetHashCode();

            for (var i = 0; i < 100; i++)
            {
                // Act
                object1.StorageDeviceInfos = new[] { device1 };
                int generatedHashCode = object1.GetHashCode();

                // Assert
                Assert.AreEqual(expectedHashcode, generatedHashCode);
            }
        }
        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()));
        }
        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);
        }
        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);
        }
        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);
        }
        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);
            }
        }
        public void Equals_TwoUninitializedObjects_ResultIsTrue()
        {
            // Arrange
            var object1 = new SystemStorageDeviceInformation();
            var object2 = new SystemStorageDeviceInformation();

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

            // Assert
            Assert.IsTrue(result);
        }