Exemple #1
0
        public void GenerateFrom_Should_Not_Throw_Exception()
        {
            var category = (Category)_domainFactory.CreateCategory("IoC/DI");

            #pragma warning disable 168
            var uniqueName = UniqueNameGenerator.GenerateFrom(_database.CategoryDataSource, category.Name);
            #pragma warning restore 168
        }
        public void Generate_Should_Return_Correct_UniqueName_When_DataSource_Is_Empty()
        {
            var database = new Mock <IDatabase>();

            database.SetupGet(d => d.CategoryDataSource).Returns(new List <Category>().AsQueryable());

            string uniqueName = UniqueNameGenerator.GenerateFrom(database.Object.CategoryDataSource, "C");

            Assert.Equal("C", uniqueName);
        }
        public void Generate_Should_Return_Correct_UniqueName_When_Second_Name_Starts_With_First_Entity_Name()
        {
            var categoryList = new List <Category>();

            var database = new Mock <IDatabase>();

            database.SetupGet(d => d.CategoryDataSource).Returns(categoryList.AsQueryable());

            var category1 = (Category)_factory.CreateCategory("IoC-DI");

            category1.UniqueName = UniqueNameGenerator.GenerateFrom(database.Object.CategoryDataSource, category1.Name);
            categoryList.Add(category1);
            Thread.Sleep(500);

            string uniqueName = UniqueNameGenerator.GenerateFrom(database.Object.CategoryDataSource, "IoC");

            Assert.Equal("IoC", uniqueName);
        }
        public void Generate_Should_Return_Correct_UniqueName_When_DataSource_Contains_One_Item()
        {
            var categoryList = new List <Category>();

            var database = new Mock <IDatabase>();

            database.SetupGet(d => d.CategoryDataSource).Returns(categoryList.AsQueryable());

            var category = (Category)_factory.CreateCategory("C");

            category.UniqueName = UniqueNameGenerator.GenerateFrom(database.Object.CategoryDataSource, category.Name);
            categoryList.Add(category);
            Thread.Sleep(500);

            string uniqueName = UniqueNameGenerator.GenerateFrom(database.Object.CategoryDataSource, "C++");

            Assert.Equal("C-2", uniqueName);
        }