Exemple #1
0
        public void AttributeStrategy_should_set_create_session_parameter()
        {
            InAuctionCreateSessionAttribute.LoadAuctionCreateSessionCommandMembers("Test.UnitTests");
            var attr = new InAuctionCreateSessionAttribute();

            var testSession      = new AuctionCreateSession(new UserIdentity(Guid.NewGuid(), "test"));
            var mockImplProvider = new Mock <IImplProvider>();
            var mockAuctionCreateSessionService = new Mock <IAuctionCreateSessionService>();

            mockAuctionCreateSessionService.Setup(service => service.GetExistingSession())
            .Returns(testSession);
            mockImplProvider.Setup(provider => provider.Get <IAuctionCreateSessionService>())
            .Returns(mockAuctionCreateSessionService.Object);

            var cmd = new TestCommandBase()
            {
                Param = 1
            };

            attr.PreHandleAttributeStrategy.Invoke(mockImplProvider.Object, cmd);

            cmd.CreateSession.Should().BeEquivalentTo(testSession);
            cmd.Param.Should().Be(1);
        }