コード例 #1
0
            public void SetsUserTokenFromUserIdentityProvider()
            {
                // Arrange
                ISetChileProductIngredientsParameters actualParams = null;

                MockProductService.Setup(m => m.SetChileProductIngredients(It.IsAny <ISetChileProductIngredientsParameters>()))
                .Callback((ISetChileProductIngredientsParameters p) => actualParams = p)
                .Returns(new SuccessResult <string>());

                const string expectedUserToken = "user13";

                MockUserTokenProvider.Setup(m => m.SetUserIdentity(It.IsAny <IUserIdentifiable>()))
                .Callback((IUserIdentifiable o) => o.UserToken = expectedUserToken);

                // Act
                SystemUnderTest.Post("2134", Fixture.Create <SetChileProductIngredientsRequest>());

                // Assert
                Assert.AreEqual(expectedUserToken, actualParams.UserToken);
                MockUserTokenProvider.Verify(m => m.SetUserIdentity(It.IsAny <IUserIdentifiable>()), Times.Once());
            }
コード例 #2
0
            public void TranslatesDtoIntoServiceParameter()
            {
                // Arrange
                ISetChileProductIngredientsParameters actualParams = null;

                MockProductService.Setup(m => m.SetChileProductIngredients(It.IsAny <ISetChileProductIngredientsParameters>()))
                .Callback((ISetChileProductIngredientsParameters p) => actualParams = p)
                .Returns(new SuccessResult <string>());

                const string expectedUserToken = "user13";

                MockUserTokenProvider.Setup(m => m.SetUserIdentity(It.IsAny <IUserIdentifiable>()))
                .Callback((IUserIdentifiable o) => o.UserToken = expectedUserToken);

                const string expectedKey = "123";
                var          param       = Fixture.Create <SetChileProductIngredientsRequest>();

                // Act
                SystemUnderTest.Post(expectedKey, param);

                // Assert
                Assert.AreEqual(expectedKey, actualParams.ChileProductKey);
                Assert.AreEqual(expectedUserToken, actualParams.UserToken);
            }