Exemplo n.º 1
0
        public void Handle_ShouldReturnSkillResponse_WhenCalledWithValidInputs()
        {
            Mock <ILogger <RemovePoints> > mockLogger = new Mock <ILogger <RemovePoints> >();

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

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

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

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

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

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

            Assert.IsType <SkillResponse>(skillResponse);
        }
Exemplo n.º 2
0
        public void Handle_ShouldThrowArgumentNullException_WhenTokenUserIsNull()
        {
            Mock <ILogger <RemovePoints> > mockLogger = new Mock <ILogger <RemovePoints> >();

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

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

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

            SkillRequest skillRequest = new SkillRequest();

            Assert.Throws <ArgumentNullException>(() => sut.Handle(skillRequest, null));
        }
Exemplo n.º 3
0
        public void Handle_ShouldThrowArgumentNullException_WhenCalledWithInvalidSkillRequest()
        {
            Mock <ILogger <RemovePoints> > mockLogger = new Mock <ILogger <RemovePoints> >();

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

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

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

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

            SkillRequest skillRequest = new SkillRequest();

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