예제 #1
0
        public void CreateLocation_BlankLegalName_ThrowsArgumentException()
        {
            var locationRepository = new Mock<ILocationRepository> ();
            var locationFactory = new LocationFactory ( locationRepository.Object );
            var agency = new Mock<Agency> ();

            locationFactory.CreateLocation ( agency.Object,
                        new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName("   ")));
        }
예제 #2
0
        public void CreateLocation_GivenValidArguments_CreatesALocation()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var locationRepository = new Mock<ILocationRepository>();
                var locationFactory = new LocationFactory(locationRepository.Object);
                var agency = new Mock<Agency>();

                var location = locationFactory.CreateLocation(
                    agency.Object, new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName(LegalName)));

                Assert.IsNotNull(location);
            }
        }
예제 #3
0
        public void CreateLocation_GivenValidArguments_LocationIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var locationRepository = new Mock<ILocationRepository>();
                var locationFactory = new LocationFactory(locationRepository.Object);
                var agency = new Mock<Agency>();

                var location = locationFactory.CreateLocation(
                    agency.Object,
                        new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName(LegalName)));

                location.ReviseLocationProfile(
                    new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName("Some Name").Build()).Build());
            }
        }
예제 #4
0
        public void CreateLocation_NullAgency_ThrowsArgumentException()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var locationRepository = new Mock<ILocationRepository>();
                var locationFactory = new LocationFactory(locationRepository.Object);

                locationFactory.CreateLocation(null, new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName(LegalName)));
            }
        }
예제 #5
0
        public void CreateLocation_GivenValidArguments_LocationIsMadePersistent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var isPersistent = false;

                var locationRepository = new Mock<ILocationRepository>();
                locationRepository.Setup(l => l.MakePersistent(It.IsAny<Location>())).Callback(() => isPersistent = true);

                var locationFactory = new LocationFactory(locationRepository.Object);
                var agency = new Mock<Agency>();

                locationFactory.CreateLocation(
                    agency.Object, new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName(LegalName)));

                Assert.IsTrue(isPersistent);
            }
        }
예제 #6
0
        public void DestroyLocation_GivenANullLocation_ThrowsArgumentException()
        {
            var locationRepository = new Mock<ILocationRepository> ();
            var locationFactory = new LocationFactory ( locationRepository.Object );

            locationFactory.DestroyLocation ( null );
        }
예제 #7
0
        public void DestroyLocation_GivenALocation_LocationIsTransient()
        {
            var isTransient = false;

            var locationRepository = new Mock<ILocationRepository> ();
            locationRepository
                .Setup ( l => l.MakeTransient ( It.IsAny<Location> () ) )
                .Callback ( () => isTransient = true );

            var locationFactory = new LocationFactory ( locationRepository.Object );
            var location = new Mock<Location> ();

            locationFactory.DestroyLocation ( location.Object );

            Assert.IsTrue ( isTransient );
        }
예제 #8
0
        public void CreateLocation_NullLegalName_ThrowsArgumentException()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var locationRepository = new Mock<ILocationRepository>();
                var locationFactory = new LocationFactory(locationRepository.Object);
                var agency = new Mock<Agency>();

                locationFactory.CreateLocation(agency.Object, null);
            }
        }