Example #1
0
        public void CreateCategoryThrowsExceptionWithInvalidNameTest(string name)
        {
            var sut = new CategoryStore(Config.Storage);

            Func <Task> action = async() => await sut.CreateCategory(CategoryGroup.Gender, name, CancellationToken.None)
                                 .ConfigureAwait(false);

            action.Should().Throw <ArgumentException>();
        }
Example #2
0
        public async Task CreateCategoryStoresNewCategoryTest()
        {
            var expected = Model.Create <Category>();

            var sut = new CategoryStore(Config.Storage);

            await sut.CreateCategory(expected.Group, expected.Name, CancellationToken.None).ConfigureAwait(false);

            var categories = await sut.GetAllCategories(CancellationToken.None).ConfigureAwait(false);

            categories.Should().Contain(x => x.Group == expected.Group && x.Name == expected.Name);
        }
Example #3
0
        public async Task CreateCategoryStoresNewCategoryWithReviewedAndVisibleAsFalseAndZeroLinkCountTest()
        {
            var expected = Model.Create <Category>();

            var sut = new CategoryStore(Config.Storage);

            await sut.CreateCategory(expected.Group, expected.Name, CancellationToken.None).ConfigureAwait(false);

            var categories = await sut.GetAllCategories(CancellationToken.None).ConfigureAwait(false);

            var actual = categories.Single(x => x.Group == expected.Group && x.Name == expected.Name);

            actual.Reviewed.Should().BeFalse();
            actual.Visible.Should().BeFalse();
            actual.LinkCount.Should().Be(0);
        }
Example #4
0
        public async Task CreateCategoryIgnoresExistingCategoryTest()
        {
            var expected = Model.Create <Category>().Set(x => x.Reviewed = true).Set(x => x.Visible = true)
                           .Set(x => x.LinkCount = Math.Abs(Environment.TickCount));

            var sut = new CategoryStore(Config.Storage);

            await sut.StoreCategory(expected, CancellationToken.None).ConfigureAwait(false);

            await sut.CreateCategory(expected.Group, expected.Name, CancellationToken.None).ConfigureAwait(false);

            var categories = await sut.GetAllCategories(CancellationToken.None).ConfigureAwait(false);

            var actual = categories.Single(x => x.Group == expected.Group && x.Name == expected.Name);

            actual.Should().BeEquivalentTo(expected);
        }
Example #5
0
 public bool CreateCategory(CategoryModel model)
 {
     try
     {
         var categoryStore = new CategoryStore();
         var dt            = categoryStore.CreateCategory(model);
         if (dt)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }