예제 #1
0
파일: Mocks.cs 프로젝트: congzw/NbCommon
 public void Config(VersionHistoryRegistry registry)
 {
     registry.AddWithAutoKey(VersionHistory.Create(VersionCategory, "1.0.0", new DateTime(2000, 1, 1), "feature 1.0.0"));
     registry.AddWithAutoKey(VersionHistory.Create(VersionCategory, "1.0.1", new DateTime(2000, 1, 2), "bug fix 1.0.1"));
     registry.AddWithAutoKey(VersionHistory.Create(VersionCategory, "1.0.2", new DateTime(2000, 1, 3), "bug fix 1.0.2"));
     registry.AddWithAutoKey(VersionHistory.Create(VersionCategory, "1.1.0", new DateTime(2000, 1, 4), "bug fix 1.1.0"));
 }
예제 #2
0
        public void AddWithAutoKey_SameCategoryAndVersion_Should_ThrowEx()
        {
            var registry = new VersionHistoryRegistry();

            registry.AddWithAutoKey(VersionHistory.Create("Demo", "1.0.0", new DateTime(2000, 1, 1), "feature 1.0.0"));
            registry.AddWithAutoKey(VersionHistory.Create("Demo", "1.0.0", new DateTime(2000, 1, 2), "bug fix 1.0.1"));
        }
예제 #3
0
        public void AddWithAutoKey_DiffCategoryAndVersion_Should_OK()
        {
            var registry = new VersionHistoryRegistry();

            registry.AddWithAutoKey(VersionHistory.Create("Demo1", "1.0.0", new DateTime(2000, 1, 1), "feature 1.0.0"));
            registry.AddWithAutoKey(VersionHistory.Create("Demo2", "1.0.0", new DateTime(2000, 1, 2), "bug fix 1.0.1"));

            registry.VersionHistories.Count.ShouldEqual(2);
            registry.VersionHistories.Values.LogProperties();
        }
예제 #4
0
        /// <summary>
        /// Factory
        /// </summary>
        /// <param name="category"></param>
        /// <param name="version"></param>
        /// <param name="description"></param>
        /// <param name="createDate"></param>
        /// <returns></returns>
        public static VersionHistory Create(string category, string version, DateTime createDate, string description)
        {
            //todo validate
            var versionHistory = new VersionHistory();

            versionHistory.Category    = category.Trim();
            versionHistory.Version     = version.Trim();
            versionHistory.Description = description;
            versionHistory.CreateDate  = createDate;
            return(versionHistory);
        }
예제 #5
0
        public VersionHistoryRegistry AddWithAutoKey(VersionHistory versionHistory)
        {
            if (versionHistory == null)
            {
                throw new ArgumentNullException("versionHistory");
            }

            if (VersionHistories == null)
            {
                VersionHistories = new VersionHistoryDictionary();
            }

            if (VersionHistories.ContainsKey(versionHistory.Id()))
            {
                throw new InvalidOperationException("重复注册: " + versionHistory.Id());
            }

            VersionHistories.Add(versionHistory.Id(), versionHistory);
            return(this);
        }