Beispiel #1
0
        public void Get_Should_ThrowException_SpecificationNotFound()
        {
            var specificationsRepository = new SpecificationsRepository(new Dictionary <Type, object>
            {
                { typeof(User), new Specification <User>(c => c) }
            });

            specificationsRepository.Get <User>();

            Assert.Throws <SpecificationNotFoundException>(() => { specificationsRepository.Get <Company>(); });
        }
Beispiel #2
0
        public void Get_Should_ThrowException_When_InvalidSpecificationRegistered()
        {
            var specificationsRepository = new SpecificationsRepository(new Dictionary <Type, object>
            {
                { typeof(User), new Specification <User>(c => c) },
                { typeof(Company), new Specification <User>(c => c) }
            });

            specificationsRepository.Get <User>();

            Assert.Throws <InvalidSpecificationTypeException>(() => { specificationsRepository.Get <Company>(); });
        }
Beispiel #3
0
        public void Get_Should_ReturnSpecification()
        {
            var userSpecification    = new Specification <User>(c => c);
            var addressSpecification = new Specification <Company>(c => c);

            var specificationsRepository = new SpecificationsRepository(new Dictionary <Type, object>
            {
                { typeof(User), userSpecification },
                { typeof(Company), addressSpecification }
            });

            Assert.Same(userSpecification, specificationsRepository.Get <User>());
            Assert.Same(addressSpecification, specificationsRepository.Get <Company>());
        }