Esempio n. 1
0
        public static void Check(Func <BloggerUnitOfWork> createUnitOfWork, IDatabaseProvider databaseProvider = null)
        {
            const string KnownEmail = "*****@*****.**";
            const string KnownTitle = "New post";

            if (databaseProvider != null)
            {
                databaseProvider.DropIfExists();
            }

            using (var unitOfWork = createUnitOfWork())
            {
                unitOfWork.BlogRepository.Save(BlogFactory.Create(KnownEmail));
                unitOfWork.Commit();
            }

            using (var unitOfWork = createUnitOfWork())
            {
                var blog = unitOfWork.BlogRepository.GetByOwner(KnownEmail);
                blog.AddPost(KnownTitle, DateTime.Now);
                unitOfWork.BlogRepository.Save(blog);
                unitOfWork.Commit();
            }

            using (var unitOfWork = createUnitOfWork())
            {
                var blog = unitOfWork.BlogRepository.GetByOwner(KnownEmail);
                blog.Posts.Single()
                .Title.Should().Be.EqualTo(KnownTitle);
            }
        }
		public static void Check(Func<BloggerUnitOfWork> createUnitOfWork, IDatabaseProvider databaseProvider = null)
		{
			const string KnownEmail = "*****@*****.**";
			const string KnownTitle = "New post";

			if (databaseProvider != null)
			{
				databaseProvider.DropIfExists();
			}

			using (var unitOfWork = createUnitOfWork())
			{
				unitOfWork.BlogRepository.Save(BlogFactory.Create(KnownEmail));
				unitOfWork.Commit();
			}

			using (var unitOfWork = createUnitOfWork())
			{
				var blog = unitOfWork.BlogRepository.GetByOwner(KnownEmail);
				blog.AddPost(KnownTitle, DateTime.Now);
				unitOfWork.BlogRepository.Save(blog);
				unitOfWork.Commit();
			}

			using (var unitOfWork = createUnitOfWork())
			{
				var blog = unitOfWork.BlogRepository.GetByOwner(KnownEmail);
				blog.Posts.Single()
					.Title.Should().Be.EqualTo(KnownTitle);
			}
		}
		public static void Check(Func<AdministrationUnitOfWork> createUnitOfWork, IDatabaseProvider databaseProvider = null)
		{
			if (databaseProvider != null)
			{
				databaseProvider.DropIfExists();
			}

			const string CustomerName = "Bill";

			using (var unitOfWork = createUnitOfWork())
			{
				unitOfWork.InvoiceRepository.Save(InvoiceFactory.ByCustomer(CustomerName, "12345"));
				unitOfWork.Commit();
			}

			using (var unitOfWork = createUnitOfWork())
			{
				var invoice = unitOfWork.InvoiceRepository.GetByCustomer(CustomerName);
				invoice.Customer.Should().Be.EqualTo(CustomerName);
			}
		}
        public static void Check(Func <AdministrationUnitOfWork> createUnitOfWork, IDatabaseProvider databaseProvider = null)
        {
            if (databaseProvider != null)
            {
                databaseProvider.DropIfExists();
            }

            const string CustomerName = "Bill";

            using (var unitOfWork = createUnitOfWork())
            {
                unitOfWork.InvoiceRepository.Save(InvoiceFactory.ByCustomer(CustomerName, "12345"));
                unitOfWork.Commit();
            }

            using (var unitOfWork = createUnitOfWork())
            {
                var invoice = unitOfWork.InvoiceRepository.GetByCustomer(CustomerName);
                invoice.Customer.Should().Be.EqualTo(CustomerName);
            }
        }