Exemple #1
0
		public void TestIgnoreDeleted()
		{
			var ctrl = new reportController();

			// Mark all books as deleted
			using(var db = new BookStoreService.Models.StoreDbContext())
			{
				var toDelete = (from i in db.Books
								where i.Deleted.HasValue == false
								select i);

				foreach(var i in toDelete)
				{
					i.Deleted = DateTime.Now;
				}

				db.SaveChanges();
			}

			{
				var result = ctrl.Get().ToArray();

				Assert.IsNotNull(result);
				Assert.IsTrue((from i in result
							   where i.BooksCount > 0
							   select i).Count() == 0);
			}

			// add one book, uncategorized
			using (var db = new BookStoreService.Models.StoreDbContext())
			{
				db.Books.Add(new Book()
				{
					ISBN = "ISBN-ISBN",
					Author = Guid.NewGuid().ToString(),
					Name = Guid.NewGuid().ToString(),
				});

				db.SaveChanges();
			}

			// check
			{
				var result = ctrl.Get().ToArray();

				Assert.IsNotNull(result);
				Assert.IsTrue((from i in result
							   where i.BooksCount > 0
							   select i).Count() == 1);

				// uncategorized always last
				Assert.IsTrue(result.Last().BooksCount == 1);
			}

		}
Exemple #2
0
		public void TestReport()
		{
			var ctrl = new reportController();

			var result = ctrl.Get();

			Assert.IsNotNull(result);

			Assert.IsNotNull(result.ToArray());
		}