protected void OnCurrentCombatStatisticsChanged(object sender, CurrentCombatStatisticsChangedEventArgs args) { Guard.WhenArgument(args, nameof(CurrentCombatStatisticsChangedEventArgs)).IsNull().Throw(); Guard.WhenArgument(args.CombatStatistics, nameof(ICombatStatistics)).IsNull().Throw(); var finalizedCombatStatistics = this.combatStatisticsFinalizationStrategy.FinalizeCombatStatistics(args.CombatStatistics); var storedCombatStatistics = this.combatStatisticsPersistentStorageStrategy.StoreCombatStatistics(finalizedCombatStatistics); }
public void CreateCorrectEventArgsInstance_WhenParametersAreValid() { // Arrange var combatStatistics = new Mock <ICombatStatistics>(); // Act var actualInstance = new CurrentCombatStatisticsChangedEventArgs(combatStatistics.Object); // Assert Assert.That(actualInstance, Is.Not.Null); Assert.That(actualInstance, Is.InstanceOf <EventArgs>()); }
public void ThrowArgumentNullException_WhenCurrentCombatStatisticsChangedEventArgsParameterIsNull() { // Arrange var commandResolutionHandler = new Mock <ICommandResolutionHandler>(); var combatStatisticsContainer = new Mock <ICombatStatisticsContainer>(); var combatStatisticsFinalizationStrategy = new Mock <ICombatStatisticsFinalizationStrategy>(); var combatStatisticsPersistentStorageStrategy = new Mock <ICombatStatisticsPersistentStorageStrategy>(); var liveCombatStatisticsCreationStrategy = new Mock <ILiveCombatStatisticsCreationStrategy>(); var logFileParserEngine = new MockLogFileParserEngine(commandResolutionHandler.Object, combatStatisticsContainer.Object, combatStatisticsFinalizationStrategy.Object, combatStatisticsPersistentStorageStrategy.Object, liveCombatStatisticsCreationStrategy.Object); CurrentCombatStatisticsChangedEventArgs args = null; // Act & Assert Assert.That( () => logFileParserEngine.OnCurrentCombatStatisticsChanged(null, args), Throws.InstanceOf <ArgumentNullException>().With.Message.Contains(nameof(CurrentCombatStatisticsChangedEventArgs))); }
public void InvokeICombatStatisticsFinalizationStrategy_FinalizeCombatStatisticsOnceWithCorrectParameter() { // Arrange var commandResolutionHandler = new Mock <ICommandResolutionHandler>(); var combatStatisticsContainer = new Mock <ICombatStatisticsContainer>(); var combatStatisticsFinalizationStrategy = new Mock <ICombatStatisticsFinalizationStrategy>(); var combatStatisticsPersistentStorageStrategy = new Mock <ICombatStatisticsPersistentStorageStrategy>(); var liveCombatStatisticsCreationStrategy = new Mock <ILiveCombatStatisticsCreationStrategy>(); var logFileParserEngine = new MockLogFileParserEngine(commandResolutionHandler.Object, combatStatisticsContainer.Object, combatStatisticsFinalizationStrategy.Object, combatStatisticsPersistentStorageStrategy.Object, liveCombatStatisticsCreationStrategy.Object); var combatStatistics = new Mock <ICombatStatistics>(); var args = new CurrentCombatStatisticsChangedEventArgs(combatStatistics.Object); // Act logFileParserEngine.OnCurrentCombatStatisticsChanged(null, args); // Assert combatStatisticsFinalizationStrategy.Verify(s => s.FinalizeCombatStatistics(args.CombatStatistics), Times.Once); }
internal new void OnCurrentCombatStatisticsChanged(object sender, CurrentCombatStatisticsChangedEventArgs args) { base.OnCurrentCombatStatisticsChanged(sender, args); }