Beispiel #1
0
        public void Get_Returns_EmptyCollection_WhenThereAreNoEntities()
        {
            OkObjectResult result;

            using (var controller = new TestBaseController(cmdQueue, Context))
            {
                result = controller.Get();
            }

            Assert.NotNull(result);
            Assert.NotNull(result.Value);
            Assert.IsAssignableFrom <IReadOnlyCollection <TestEventSourced> >(result.Value);
        }
Beispiel #2
0
        public void Get_ById_Returns_NotFound_WhenIdDoesNotMatch()
        {
            using (var context = Context())
            {
                context.AddRange(TestItems);
                context.SaveChanges();
            }

            NotFoundResult result;

            using (var controller = new TestBaseController(cmdQueue, Context))
            {
                result = controller.Get(Guid.NewGuid()) as NotFoundResult;
            }

            Assert.IsType <NotFoundResult>(result);
        }
Beispiel #3
0
        public void Get_ById_Returns_FoundEntity()
        {
            using (var context = Context())
            {
                context.AddRange(TestItems);
                context.SaveChanges();
            }

            OkObjectResult result;

            using (var controller = new TestBaseController(cmdQueue, Context))
            {
                result = controller.Get(TestItems[1].Id) as OkObjectResult;
            }

            Assert.IsType <OkObjectResult>(result);
            Assert.IsType <TestEventSourced>(result.Value);
            Assert.Equal(TestItems[1].Id, (result.Value as TestEventSourced).Id);
        }
Beispiel #4
0
        public void Get_Returns_AllNonDeletedItems()
        {
            using (var context = Context())
            {
                context.AddRange(TestItems);
                context.SaveChanges();
            }

            OkObjectResult result;

            using (var controller = new TestBaseController(cmdQueue, Context))
            {
                result = controller.Get();
            }

            Assert.IsAssignableFrom <IReadOnlyCollection <TestEventSourced> >(result.Value);

            var data = result.Value as IReadOnlyCollection <TestEventSourced>;

            Assert.Equal(2, data.Count());
            Assert.DoesNotContain(data, d => d.Id == TestItems[0].Id);
            Assert.Contains(data, d => d.Id == TestItems[1].Id);
            Assert.Contains(data, d => d.Id == TestItems[2].Id);
        }