コード例 #1
0
        public async Task AddNewGoal()
        {
            // Arrange
            var handler = new GoalEditCommandHandler(Context);
            var newGoal = new GoalEditViewModel { GoalType = GoalType.Numeric, CurrentGoalLevel = 123, NumericGoal = 456, CampaignId = 98, TextualGoal = "We aim to please", Display = true };


            // Act
            var result = await handler.Handle(new GoalEditCommand { Goal = newGoal });

            // Assert
            Assert.Equal(8, Context.CampaignGoals.Count());
            Assert.Equal(8, result);
        }
コード例 #2
0
        public async Task UpdatingExistingGoal()
        {
            // Arrange
            var handler = new GoalEditCommandHandler(Context);
            var newGoal = new GoalEditViewModel { Id = 2, GoalType = GoalType.Numeric, CurrentGoalLevel= 123, NumericGoal = 456, CampaignId = 98, TextualGoal = "We aim to please", Display = true};

            // Act
            var result = await handler.Handle(new GoalEditCommand { Goal = newGoal });
            var savedGoal = Context.CampaignGoals.SingleOrDefault(s => s.Id == 2);

            // Assert
            Assert.Equal(7, Context.CampaignGoals.Count());
            Assert.Equal(2, result);
            Assert.Equal("We aim to please", savedGoal.TextualGoal);
        }