private byte[] SerializeSession(AuctionCreateSession session)
        {
            var json = JsonConvert.SerializeObject(session, new JsonSerializerSettings()
            {
            });

            return(Encoding.UTF8.GetBytes(json));
        }
Example #2
0
        public IAuctionCreateSessionService GetAuctionCreateSessionService(AuctionCreateSession session)
        {
            var service = new Mock <IAuctionCreateSessionService>();

            service.Setup(f => f.GetExistingSession())
            .Returns(session);
            service.Setup(f => f.RemoveSession());
            return(service.Object);
        }
        public void SaveSession(AuctionCreateSession session)
        {
            var user        = GetSignedInUserIdentity();
            var key         = GetSessionKey(user);
            var httpContext = _httpContextAccessor.HttpContext;

            _logger.LogDebug("Saving modified AuctionCreateSession {@session} for {@user} with key: {key}", session, user, key);
            httpContext.Session.Set(key, SerializeSession(session));
        }
Example #4
0
        public void SetUp()
        {
            var services = TestDepedencies.Instance.Value;

            user = new User();
            user.Register("testUserName");
            user.MarkPendingEventsAsHandled();
            session = user.UserIdentity.GetAuctionCreateSession();
            product = new Product("test product name", "example description", Condition.New);
            services.DbContext.UsersReadModel.InsertOne(new UserRead()
            {
                UserIdentity = new UserIdentityRead(user.UserIdentity)
            });
        }
Example #5
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);
        }