public void Default_StorageDeviceInfos_IsNull()
        {
            // Arrange
            var processorUtilizationInformation = new SystemStorageInformation();

            // Assert
            Assert.IsNull(processorUtilizationInformation.StorageDeviceInfos);
        }
        public void Equals_SuppliedObjectIsOfOtherType_ResultIsFalse()
        {
            // Arrange
            var object1 = new SystemStorageInformation { StorageDeviceInfos = new[] { new SystemStorageDeviceInformation { DeviceName = "C:", FreeDiscSpaceInPercent = 50.0d } } };
            var object2 = new object();

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

            // Assert
            Assert.IsFalse(result);
        }
        public void GetStorageUtilizationInPercent_SystemStorageInformationParameterDeviceInfoPropertyIsNull_ResultIsEmpty()
        {
            // Arrange
            var systemStorageInformation = new SystemStorageInformation { StorageDeviceInfos = null };
            var storageStatusOrchestrator = new StorageStatusOrchestrator();

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

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

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

            // Assert
            Assert.IsTrue(result);
        }
        public IEnumerable<SystemStatusPointViewModel> GetStorageUtilizationInPercent(SystemStorageInformation systemStorageInformation)
        {
            if (systemStorageInformation == null)
            {
                throw new ArgumentNullException("systemStorageInformation");
            }

            if (systemStorageInformation.StorageDeviceInfos == null || systemStorageInformation.StorageDeviceInfos.Length == 0)
            {
                return new SystemStatusPointViewModel[] { };
            }

            return systemStorageInformation.StorageDeviceInfos.Select(deviceInfo => new SystemStatusPointViewModel
                {
                    Name = string.Format(StorageUtilizationDataSeriesNamePattern, deviceInfo.DeviceName),
                    Value = 100d - deviceInfo.FreeDiscSpaceInPercent
                });
        }
        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 GetHashCode_SameHashCodeIsReturnedEveryTimeTheMethodIsCalled_AsLongAsTheObjectDoesNotChange()
        {
            // Arrange
            var memoryStatus = new SystemMemoryInformation { AvailableMemoryInGB = 3 };
            var processorStatus = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 30d };
            var storageStatus = new SystemStorageInformation();

            var object1 = new SystemPerformanceData { MemoryStatus = memoryStatus, ProcessorStatus = processorStatus, StorageStatus = storageStatus };

            int expectedHashcode = object1.GetHashCode();

            for (var i = 0; i < 100; i++)
            {
                // Act
                object1.MemoryStatus = memoryStatus;
                object1.ProcessorStatus = processorStatus;
                object1.StorageStatus = storageStatus;

                int generatedHashCode = object1.GetHashCode();

                // Assert
                Assert.AreEqual(expectedHashcode, generatedHashCode);
            }
        }
        public void GetHashCode_ForAllUniqueObject_AUniqueHashCodeIsReturned()
        {
            var hashCodes = new Dictionary<int, SystemStorageInformation>();

            for (var i = 0; i < 10000; i++)
            {
                // Act
                var object1 = new SystemStorageInformation { StorageDeviceInfos = new[] { new SystemStorageDeviceInformation { DeviceName = "C:", 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 SystemStorageInformation();
            var object2 = new SystemStorageInformation();

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

            // Assert
            Assert.IsTrue(result);
        }
        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_TwoIdenticalObjects_BothUninitialized_HashCodesAreEqual()
        {
            // Arrange
            var package1 = new SystemStorageInformation();
            var package2 = new SystemStorageInformation();

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

            // Assert
            Assert.AreEqual(hashCodeObject1, hashCodeObject2);
        }
        public void GetHashCode_TwoIdenticalObjects_BothInitialized_HashCodesAreEqual()
        {
            // Arrange
            var object1 = new SystemStorageInformation { StorageDeviceInfos = new[] { new SystemStorageDeviceInformation { DeviceName = "C:", FreeDiscSpaceInPercent = 50.0d } } };
            var object2 = new SystemStorageInformation { StorageDeviceInfos = new[] { new SystemStorageDeviceInformation { DeviceName = "C:", FreeDiscSpaceInPercent = 50.0d } } };

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

            // Assert
            Assert.AreEqual(hashCodeObject1, hashCodeObject2);
        }
        public void GetHashCode_TwoDistinctObjects_HashCodesAreDifferent()
        {
            // Arrange
            var object1 = new SystemStorageInformation { StorageDeviceInfos = new[] { new SystemStorageDeviceInformation { DeviceName = "C:", FreeDiscSpaceInPercent = 50.0d } } };
            var object2 = new SystemStorageInformation { StorageDeviceInfos = new[] { new SystemStorageDeviceInformation { DeviceName = "D:", FreeDiscSpaceInPercent = 50.0d } } };

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

            // Assert
            Assert.AreNotEqual(hashCodeObject1, hashCodeObject2);
        }
        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);
            }
        }