Example #1
0
        public void AddExistingItemToStoreable()
        {
            IStoreable addStorable = new Storable();

            addStorable.Id = 1;
            RepositoryImplementation <IStoreable> ri = new RepositoryImplementation <IStoreable>();

            ri.Save(addStorable);
            ri.Save(addStorable);
        }
Example #2
0
        public void AddNewItemToStoreable()
        {
            IStoreable addStorable = new Storable();

            addStorable.Id = 1;
            RepositoryImplementation <IStoreable> ri = new RepositoryImplementation <IStoreable>();

            ri.Save(addStorable);
            Assert.IsTrue(1 == (int)addStorable.Id);
            IStoreable retStorable = ri.FindById(addStorable.Id);

            Assert.IsTrue(retStorable.Id == addStorable.Id);
        }
        internal override void Start()
        {
            foreach (var item in dataList)
            {
                Data = item;
                var codeDom = Render();

                var filePath = $"{Path}/{item.Class}{FileExtension}";

                if (!WriteToFile(filePath, codeDom))
                {
                    Console.WriteLine("It can be not write to file!");
                }
            }
        }
Example #4
0
        public void GetStorableItemByInvalidId()
        {
            IStoreable addStorable = new Storable();

            addStorable.Id = 1;
            RepositoryImplementation <IStoreable> ri = new RepositoryImplementation <IStoreable>();

            ri.Save(addStorable);
            addStorable.Id = 2;
            ri.Save(addStorable);
            addStorable.Id = 3;
            ri.Save(addStorable);

            IStoreable retVal = ri.FindById(4);

            Assert.IsTrue((int)retVal.Id == 4);
        }
Example #5
0
        public void GetAllStorableItem()
        {
            IStoreable addStorable = new Storable();

            addStorable.Id = 1;
            RepositoryImplementation <IStoreable> ri = new RepositoryImplementation <IStoreable>();

            ri.Save(addStorable);
            addStorable.Id = 2;
            ri.Save(addStorable);
            addStorable.Id = 3;
            ri.Save(addStorable);

            List <IStoreable> allStore = ri.All().ToList();

            Assert.IsTrue(allStore.Count == 3);
        }
        private void LogHistoryTrackerEvent(IEnumerable <DbEntityEntry> changedEntities)
        {
            //var baseImplementation = ResolveRepositoryBaseImplementation();
            //if (baseImplementation == null) return;

            var entities = changedEntities.Where(w => ObjectContext.GetObjectType(w.Entity.GetType()).GetInterfaces().Contains(typeof(IHistoryTracker)));

            foreach (var entity in entities)
            {
                RepositoryImplementation.LogHistoryTracking(entity);
            }

            var dynamicEntites = changedEntities.Where(w => ObjectContext.GetObjectType(w.Entity.GetType()).GetInterfaces().Contains(typeof(IDynamicHistoryTracker)));

            foreach (var entity in dynamicEntites)
            {
                RepositoryImplementation.LogDynamicHistoryTracking(entity);
            }
        }
Example #7
0
        public void DeleteStorableItemByExistingId()
        {
            IStoreable addStorable = new Storable();

            addStorable.Id = 1;
            RepositoryImplementation <IStoreable> ri = new RepositoryImplementation <IStoreable>();

            ri.Save(addStorable);
            addStorable.Id = 2;
            ri.Save(addStorable);
            addStorable.Id = 3;
            ri.Save(addStorable);

            List <IStoreable> preDeleteCount = ri.All().ToList();

            ri.Delete(3);

            List <IStoreable> postDeleteCount = ri.All().ToList();

            Assert.IsTrue(preDeleteCount.Count == (postDeleteCount.Count + 1));
        }
Example #8
0
        public void DeleteStorableItemByInvalidIdNoDeleteionTalkesPlaceNoErrors()
        {
            IStoreable addStorable = new Storable();

            addStorable.Id = 1;
            RepositoryImplementation <IStoreable> ri = new RepositoryImplementation <IStoreable>();

            ri.Save(addStorable);
            addStorable.Id = 2;
            ri.Save(addStorable);
            addStorable.Id = 3;
            ri.Save(addStorable);

            List <IStoreable> preDeleteCount = ri.All().ToList();

            ri.Delete(4);

            List <IStoreable> postDeleteCount = ri.All().ToList();

            Assert.IsTrue(preDeleteCount.Count == (postDeleteCount.Count));
        }
Example #9
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");
            this.Write("\r\n");
            this.Write("\r\n");
            this.Write("\r\n");
            this.Write("\r\n\r\n");

            #line 18 "C:\workgit\oyasar.codegenerator\OYASAR.CodeGenerator.Lib\TextTemplate\RepositoryImplementationTemplate.tt"
            RepositoryImplementation model = RepositoryImplementationManager.Data;

            #line default
            #line hidden
            this.Write("\r\n\r\nusing Microsoft.EntityFrameworkCore;\r\nusing System;\r\nusing System.Collections" +
                       ".Generic;\r\nusing System.Linq;\r\n\r\nnamespace ");

            #line 26 "C:\workgit\oyasar.codegenerator\OYASAR.CodeGenerator.Lib\TextTemplate\RepositoryImplementationTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(model.NameSpace));

            #line default
            #line hidden
            this.Write("\r\n{\r\n    public partial class ");

            #line 28 "C:\workgit\oyasar.codegenerator\OYASAR.CodeGenerator.Lib\TextTemplate\RepositoryImplementationTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(model.Class));

            #line default
            #line hidden
            this.Write("Repository : I");

            #line 28 "C:\workgit\oyasar.codegenerator\OYASAR.CodeGenerator.Lib\TextTemplate\RepositoryImplementationTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(model.Class));

            #line default
            #line hidden
            this.Write("Repository\r\n    {        \r\n    }\r\n}\r\n");
            return(this.GenerationEnvironment.ToString());
        }