コード例 #1
0
        public void Handle_ShouldThrowArgumentNullException_WhenTokenUserIsNull()
        {
            Mock <ILogger <ResetAllPoints> > mockLogger = new Mock <ILogger <ResetAllPoints> >();

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

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

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

            SkillRequest skillRequest = new SkillRequest();

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

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

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

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

            SkillRequest skillRequest = GenerateValidSkillRequest(new IntentRequest()
            {
                RequestId = "TestRequestId",
                Locale    = "en-US",
                Type      = "IntentRequest",
                Intent    = new Intent()
                {
                    ConfirmationStatus = "CONFIRMED",
                    Name  = "ResetAllPoints",
                    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 <ResetAllPoints> > mockLogger = new Mock <ILogger <ResetAllPoints> >();

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

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

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

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

            SkillRequest skillRequest = new SkillRequest();

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