Пример #1
0
        public void Fetching_provider_should_be_mockable()
        {
            Product product = new Product { Price = 10 };
            IRepository<Product> products = new FakeRepository<Product> { product };

            ProductsCalculator calculator = new ProductsCalculator(products);

            double totalPrice = calculator.GetTotalPrice();

            Assert.That(totalPrice, Is.EqualTo(10));
        }
Пример #2
0
        public void Should_work_with_nhibernate()
        {
            Configuration configuration = new Configuration();
            configuration.SessionFactory()
                .Integrate.Using<SQLiteDialect>()
                .Connected.Using(new SQLiteConnectionStringBuilder{DataSource = ":memory:", Version = 3}).LogSqlInConsole();
            configuration.AddDeserializedMapping(DomainMapper.GetMappings(), "domain");

            using(var factory = configuration.BuildSessionFactory())
            {
                using(var session = factory.OpenSession())
                {
                    new SchemaExport(configuration).Execute(true, true, false, session.Connection, Console.Out);
                    ProductsCalculator productsCalculator = new ProductsCalculator(new Repository<Product>(session));
                    var price = productsCalculator.GetTotalPrice();

                    Assert.That(price, Is.EqualTo(0));
                }
            }
        }