示例#1
0
        public void SyncInfoShouldThrowOnNull()
        {
            var service = new VippsLoginCommerceService(
                A.Fake <IVippsLoginService>(),
                A.Fake <IVippsLoginMapper>(),
                A.Fake <IVippsLoginDataLoader>(),
                A.Fake <ICustomerContactService>());

            Assert.Throws <ArgumentNullException>(() => service.SyncInfo(null, null));
            Assert.Throws <ArgumentNullException>(() => service.SyncInfo(new ClaimsIdentity(), null));
            Assert.Throws <ArgumentNullException>(() => service.SyncInfo(null, new CustomerContact()));
        }
示例#2
0
        public void SyncInfoShouldSyncAddressInfo()
        {
            var contact = A.Fake <CustomerContact>();

            var userInfo = new VippsUserInfo()
            {
                Sub       = Guid.NewGuid(),
                Addresses = new[] { new VippsAddress(), new VippsAddress() }
            };
            var identity     = new ClaimsIdentity();
            var loginService = A.Fake <IVippsLoginService>();

            A.CallTo(() => loginService.GetVippsUserInfo(A <IIdentity> ._))
            .Returns(userInfo);

            var mapper  = A.Fake <IVippsLoginMapper>();
            var service = new VippsLoginCommerceService(
                loginService,
                mapper,
                A.Fake <IVippsLoginDataLoader>(), A.Fake <ICustomerContactService>());

            service.SyncInfo(identity, contact, new VippsSyncOptions
            {
                SyncContactInfo   = false,
                SyncAddresses     = true,
                ShouldSaveContact = false,
            });

            A.CallTo(() => mapper.MapAddress(null, CustomerAddressTypeEnum.Billing, null, String.Empty))
            .WithAnyArguments()
            .MustHaveHappenedTwiceExactly();
        }
示例#3
0
        public void SyncInfoShouldNotSyncUserInfo()
        {
            var userinfo = new VippsUserInfo()
            {
                Addresses = Enumerable.Empty <VippsAddress>()
            };
            var loginService = A.Fake <IVippsLoginService>();

            A.CallTo(() => loginService.GetVippsUserInfo(A <ClaimsIdentity> ._)).Returns(userinfo);
            var mapper  = A.Fake <IVippsLoginMapper>();
            var service = new VippsLoginCommerceService(
                loginService,
                mapper,
                A.Fake <IVippsLoginDataLoader>(),
                A.Fake <ICustomerContactService>());

            service.SyncInfo(new ClaimsIdentity(), new CustomerContact(), new VippsSyncOptions
            {
                SyncContactInfo   = false,
                SyncAddresses     = false,
                ShouldSaveContact = false,
            });

            A.CallTo(() => mapper.MapVippsAddressFields(A <CustomerAddress> ._, A <VippsAddress> ._)).MustNotHaveHappened();
        }