public void Default_ProcessorUtilizationInPercent_IsSetToZero() { // Arrange var processorUtilizationInformation = new ProcessorUtilizationInformation(); // Assert Assert.AreEqual(0.0d, processorUtilizationInformation.ProcessorUtilizationInPercent); }
public SystemStatusPointViewModel GetProcessorUtilizationInPercent(ProcessorUtilizationInformation processorUtilizationInformation) { if (processorUtilizationInformation == null) { throw new ArgumentNullException("processorUtilizationInformation"); } return new SystemStatusPointViewModel { Name = CPUUtilizationDataSeriesName, Value = processorUtilizationInformation.ProcessorUtilizationInPercent }; }
public void Equals_TwoUninitializedObjects_ResultIsTrue() { // Arrange var object1 = new ProcessorUtilizationInformation(); var object2 = new ProcessorUtilizationInformation(); // Act bool result = object1.Equals(object2); // Assert Assert.IsTrue(result); }
public void Equals_TwoIdenticalInitializedObjects_ResultIsTrue() { // Arrange var object1 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 50.0d }; var object2 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 50.0d }; // Act bool result = object1.Equals(object2); // Assert Assert.IsTrue(result); }
public void Equals_SuppliedObjectIsOfOtherType_ResultIsFalse() { // Arrange var object1 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 50.0d }; var object2 = new object(); // Act bool result = object1.Equals(object2); // Assert Assert.IsFalse(result); }
public void GetHashCode_ForAllUniqueObject_AUniqueHashCodeIsReturned() { var hashCodes = new Dictionary<int, ProcessorUtilizationInformation>(); for (var i = 0; i < 100; i++) { // Act var object1 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = i }; int generatedHashCode = object1.GetHashCode(); // Assert Assert.IsFalse(hashCodes.ContainsKey(generatedHashCode)); hashCodes.Add(generatedHashCode, object1); } }
public void ToString_Contains_ProcessorUtilizationInPercent() { // Arrange var object1 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 50.0d }; // Act string result = object1.ToString(); // Assert Assert.IsTrue(result.Contains(object1.ProcessorUtilizationInPercent.ToString())); }
public void GetHashCode_TwoIdenticalObjects_BothUninitialized_HashCodesAreEqual() { // Arrange var package1 = new ProcessorUtilizationInformation(); var package2 = new ProcessorUtilizationInformation(); // Act int hashCodeObject1 = package1.GetHashCode(); int hashCodeObject2 = package2.GetHashCode(); // Assert Assert.AreEqual(hashCodeObject1, hashCodeObject2); }
public void GetHashCode_TwoIdenticalObjects_BothInitialized_HashCodesAreEqual() { // Arrange var object1 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 50.0d }; var object2 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 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 ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 90.0d }; var object2 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 10.0d }; // Act int hashCodeObject1 = object1.GetHashCode(); int hashCodeObject2 = object2.GetHashCode(); // Assert Assert.AreNotEqual(hashCodeObject1, hashCodeObject2); }
public void GetHashCode_SameHashCodeIsReturnedEveryTimeTheMethodIsCalled_AsLongAsTheObjectDoesNotChange() { // Arrange var processorUtilizationInPercent = 50.0d; var object1 = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = processorUtilizationInPercent }; int expectedHashcode = object1.GetHashCode(); for (var i = 0; i < 100; i++) { // Act object1.ProcessorUtilizationInPercent = processorUtilizationInPercent; int generatedHashCode = object1.GetHashCode(); // Assert Assert.AreEqual(expectedHashcode, generatedHashCode); } }
public void GetSystemStatusViewModel_ProcessorStatusIsNotNull_ResultContainsProcessorStatusDataPoint() { // Arrage var processorStatus = new ProcessorUtilizationInformation { ProcessorUtilizationInPercent = 50d }; var systemPerformanceInformation = new SystemPerformanceData { ProcessorStatus = processorStatus }; var systemInformation = new SystemInformation { SystemPerformance = systemPerformanceInformation }; var processorStatusViewModel = new SystemStatusPointViewModel { Name = "Processor Status", Value = processorStatus.ProcessorUtilizationInPercent }; var processorStatusOrchestrator = new Mock<IProcessorStatusOrchestrator>(); processorStatusOrchestrator.Setup(p => p.GetProcessorUtilizationInPercent(It.IsAny<ProcessorUtilizationInformation>())).Returns( processorStatusViewModel); var memoryStatusOrchestrator = new Mock<IMemoryStatusOrchestrator>(); var storageStatusOrchestrator = new Mock<IStorageStatusOrchestrator>(); var systemStatusOrchestrator = new SystemStatusOrchestrator( processorStatusOrchestrator.Object, memoryStatusOrchestrator.Object, storageStatusOrchestrator.Object); // Act var result = systemStatusOrchestrator.GetSystemStatusViewModel(systemInformation); // Assert Assert.AreEqual(processorStatusViewModel.Value, result.DataPoints.First(d => d.Name.Equals(processorStatusViewModel.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); } }