예제 #1
0
        public async Task UpdateWithNonUniqueName_ThrowsArgumentException()
        {
            _queriesMock.Setup(m => m.GetByName(It.IsAny <int>(), It.IsAny <string>())).Returns <int, string>(
                (id, s) => Task.FromResult(new Category {
                Id = 1, Name = "New category"
            }));

            var categoriesCommands = new CategoriesCommands(
                _repository, _productCommandsMock.Object, _productQueriesMock.Object, _currentSessionMock.Object);
            var model = new CategoryModel {
                Name = "New category"
            };
            await Assert.ThrowsAsync <ArgumentException>(async() => await categoriesCommands.Update(model));
        }
예제 #2
0
        public void UpdateWithUniqueName_UpdatesNormal()
        {
            var categoriesCommands = new CategoriesCommands(
                _repository, _productCommandsMock.Object, _productQueriesMock.Object, _currentSessionMock.Object);
            var model = new CategoryModel {
                Id = -1, Name = "New category"
            };
            var t = categoriesCommands.Update(model);

            t.Wait();

            _commandsMock.Verify(m => m.Create(It.IsAny <Category>()));
            _uowMock.Verify(m => m.SaveChangesAsync());
        }