コード例 #1
0
        public void ShouldAddCustomerLogin(int customerId)
        {
            // arrange
            var customer = new Mock <ICustomer>();

            _context.Customers.Setup(x => x.GetById(100)).Returns(customer.Object);

            ILoginInfo addedLogin = null;

            customer.Setup(x => x.AddLogin(It.IsAny <ILoginInfo>())).Callback((ILoginInfo i) => addedLogin = i);

            // act
            _service.AddCustomerLogin(customerId, "provider", "login");

            // assert
            addedLogin.ShouldNotBeNull();
            addedLogin.ProviderName.ShouldBe("provider");
            addedLogin.LoginKey.ShouldBe("login");
            _context.Customers.Verify(x => x.Update(customer.Object));
        }