Beispiel #1
0
        public void post_Todo_should_add_item_and_save_changes()
        {
            var mockTodoItemsDataAccess = MockRepository.Create <IListDataAccess>();

            mockTodoItemsDataAccess.SetupAllProperties();

            var mockDocumentSession = MockRepository.Create <IDocumentSession>();

            mockDocumentSession.SetupAllProperties();

            var endpoint = new TodoItemEndpoint(mockTodoItemsDataAccess.Object,
                                                mockDocumentSession.Object);
            var todo = new TodoItem {
                Id = "1", Text = "do some stuff"
            };

            var result = endpoint.post_Todo(todo);

            mockTodoItemsDataAccess.Verify(da => da.StoreItem(todo));
            mockDocumentSession.Verify(ds => ds.SaveChanges());
        }
Beispiel #2
0
        public void get_Todo_List_should_call_DataAccess_LoadItems()
        {
            var mockTodoItemsDataAccess = MockRepository.Create <IListDataAccess>();
            var mockDocumentSession     = MockRepository.Create <IDocumentSession <RavenDbSettings> >();
            var itemsToReturn           = new List <TodoItem> {
                new TodoItem {
                    Text = "item1 "
                }, new TodoItem()
            };

            mockTodoItemsDataAccess.Verify(x => x.LoadItems());
            mockTodoItemsDataAccess.Object.LoadItems().ShouldBe(itemsToReturn);

            var endpoint = new TodoItemEndpoint(mockTodoItemsDataAccess.Object, mockDocumentSession.Object);

            var result = endpoint.get_Todo_List();

            mockTodoItemsDataAccess.Verify(x => x.LoadItems());
            result.ShouldBeOfType(typeof(ListItemsViewModel));
            result.Count.ShouldBe(2);
        }
Beispiel #3
0
        public void get_Todo_should_call_GetTodoItem_from_dataAccess_with_correct_params()
        {
            var mockTodoItemsDataAccess = MockRepository.Create <IListDataAccess>();

            mockTodoItemsDataAccess.SetupAllProperties();

            var mockDocumentSession = MockRepository.Create <IDocumentSession>();

            mockDocumentSession.SetupAllProperties();

            var todoGetReqeust = new TodoGetRequest {
                Id = "item1"
            };

            var endpoint = new TodoItemEndpoint(mockTodoItemsDataAccess.Object,
                                                mockDocumentSession.Object);

            endpoint.get_Todo(todoGetReqeust);

            mockTodoItemsDataAccess.Verify(
                todoItemDataAccess => todoItemDataAccess.GetItem(todoGetReqeust.Id));
        }