public void GetCurrencyCodeWillReturnDefaultCurrencyCodeWhenProfileIsNotUserProfile()
        {
            // Fixture setup
            var profile = new Mock <ProfileBase>().Object;

            var httpContextStub = new Mock <HttpContextBase>();

            httpContextStub.SetupGet(ctx => ctx.Profile).Returns(profile);

            var sut = new DefaultCurrencyProfileService(httpContextStub.Object);
            // Exercise system
            var result = sut.GetCurrencyCode();

            // Verify outcome
            Assert.Equal <string>("DKK", result);
            // Teardown
        }
        public void UpdateCurrencyCodeWhenProfileIsNotUserProfileWillThrow()
        {
            // Fixture setup
            var fixture = new Fixture();
            var profile = new Mock <ProfileBase>().Object;

            var httpContextStub = new Mock <HttpContextBase>();

            httpContextStub.SetupGet(ctx => ctx.Profile).Returns(profile);

            var sut = new DefaultCurrencyProfileService(httpContextStub.Object);

            // Exercise system and verify outcome
            Assert.Throws <InvalidOperationException>(() =>
                                                      fixture.Do((string currencyCode) =>
                                                                 sut.UpdateCurrencyCode(currencyCode)));
            // Teardown
        }
        public void GetCurrencyCodeWillReturnDefaultCurrencyCodeWhenUserProfileCurrencyIsNull()
        {
            // Fixture setup
            var userProfileStub = new Mock <UserProfile>();

            userProfileStub.SetupGet(up => up.Currency).Returns((string)null);

            var httpContextStub = new Mock <HttpContextBase>();

            httpContextStub.SetupGet(ctx => ctx.Profile).Returns(userProfileStub.Object);

            var sut = new DefaultCurrencyProfileService(httpContextStub.Object);
            // Exercise system
            var result = sut.GetCurrencyCode();

            // Verify outcome
            Assert.Equal <string>("DKK", result);
            // Teardown
        }
        public void GetCurrencyCodeWillReturnProfileFromContextWhenThatProfileIsUserProfile()
        {
            // Fixture setup
            var fixture = new ControllerFixture();
            var expectedCurrencyCode = fixture.CreateAnonymous("CurrencyCode");

            var userProfileStub = new Mock <UserProfile>();

            userProfileStub.SetupGet(up => up.Currency).Returns(expectedCurrencyCode);

            var httpContextStub = new Mock <HttpContextBase>();

            httpContextStub.SetupGet(ctx => ctx.Profile).Returns(userProfileStub.Object);

            var sut = new DefaultCurrencyProfileService(httpContextStub.Object);
            // Exercise system
            var result = sut.GetCurrencyCode();

            // Verify outcome
            Assert.Equal <string>(expectedCurrencyCode, result);
            // Teardown
        }
        public void UpdateCurrencyCodeWillSaveProfile()
        {
            // Fixture setup
            var fixture      = new Fixture();
            var currencyCode = fixture.CreateAnonymous("CurrencyCode");

            var userProfileMock = new Mock <UserProfile>();

            userProfileMock.SetupSet(up => up.Currency = currencyCode).Verifiable();
            userProfileMock.Setup(up => up.Save()).Verifiable();

            var httpContextStub = new Mock <HttpContextBase>();

            httpContextStub.SetupGet(ctx => ctx.Profile).Returns(userProfileMock.Object);

            var sut = new DefaultCurrencyProfileService(httpContextStub.Object);

            // Exercise system
            sut.UpdateCurrencyCode(currencyCode);
            // Verify outcome
            userProfileMock.Verify();
            // Teardown
        }