示例#1
0
        public void Handle_ShouldThrowArgumentNullException_WhenTokenUserIsNull()
        {
            Mock <ILogger <GetPointsAverage> > mockLogger = new Mock <ILogger <GetPointsAverage> >();

            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(true);

            GetPointsAverage sut = new GetPointsAverage(mockLogger.Object, mockSkillRequestValidator.Object);

            SkillRequest skillRequest = new SkillRequest();

            Assert.Throws <ArgumentNullException>(() => sut.Handle(skillRequest, null));
        }
示例#2
0
        public void Handle_ShouldReturnSkillResponse_WhenCalledWithValidInputs()
        {
            Mock <ILogger <GetPointsAverage> > mockLogger = new Mock <ILogger <GetPointsAverage> >();

            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(true);

            GetPointsAverage sut = new GetPointsAverage(mockLogger.Object, mockSkillRequestValidator.Object);

            SkillRequest skillRequest = GenerateValidSkillRequest(new IntentRequest()
            {
                RequestId = "TestRequestId",
                Locale    = "en-US",
                Type      = "IntentRequest",
                Intent    = new Intent()
                {
                    ConfirmationStatus = "CONFIRMED",
                    Name  = "GetPointsAverage",
                    Slots = new Dictionary <string, Slot>()
                    {
                        {
                            "player",
                            new Slot()
                            {
                                Name  = "player",
                                Value = "blue",
                                ConfirmationStatus = "NONE"
                            }
                        }
                    }
                }
            });

            TokenUser tokenUser = new TokenUser()
            {
                Players = new List <Player>()
            };

            SkillResponse skillResponse = sut.Handle(skillRequest, tokenUser);

            Assert.IsType <SkillResponse>(skillResponse);
        }
示例#3
0
        public void Handle_ShouldThrowArgumentNullException_WhenCalledWithInvalidSkillRequest()
        {
            Mock <ILogger <GetPointsAverage> > mockLogger = new Mock <ILogger <GetPointsAverage> >();

            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(false);

            GetPointsAverage sut = new GetPointsAverage(mockLogger.Object, mockSkillRequestValidator.Object);

            TokenUser tokenUser = new TokenUser()
            {
                Players = new List <Player>()
            };

            SkillRequest skillRequest = new SkillRequest();

            Assert.Throws <ArgumentNullException>(() => sut.Handle(skillRequest, tokenUser));
        }