예제 #1
0
        public void CreateNew()
        {
            var testClass = new AutomaticIdGuidClass();
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());

            testClass = Modl<AutomaticIdGuidClass>.New();
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());

            var id = Guid.NewGuid();
            testClass = Modl<AutomaticIdGuidClass>.New(id);
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.True(testClass.Id().Equals(id));
            Assert.True(id == testClass.Id());
            Assert.Equal(id, testClass.CustomId);
        }
예제 #2
0
        public void SetId()
        {
            var id        = Guid.NewGuid();
            var testClass = new AutomaticIdGuidClass();

            testClass.Id(id);
            Assert.Equal(id, testClass.Id().Get());
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.Equal(id, testClass.CustomId);
        }
예제 #3
0
        public void CreateNew()
        {
            var testClass = new AutomaticIdGuidClass();

            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());

            testClass = Modl <AutomaticIdGuidClass> .New();

            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());

            var id = Guid.NewGuid();

            testClass = Modl <AutomaticIdGuidClass> .New(id);

            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.True(testClass.Id().Equals(id));
            Assert.True(id == testClass.Id());
            Assert.Equal(id, testClass.CustomId);
        }
예제 #4
0
        public void Save()
        {
            var testClass = new AutomaticIdGuidClass();
            var id        = testClass.Id();

            testClass.Save();
            Assert.False(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.Equal(id, testClass.Id());
            Assert.True(id == testClass.CustomId);

            var loadedTestClass = Modl <AutomaticIdGuidClass> .Get(id);

            Assert.True(id == loadedTestClass.CustomId);
            Assert.Equal(id, loadedTestClass.Id());
            Assert.True(id == loadedTestClass.CustomId);
            Assert.False(loadedTestClass.IsNew());
            Assert.False(loadedTestClass.IsModified());
            Assert.Throws <InvalidIdException>(() => loadedTestClass.Id(Guid.NewGuid()));
        }
예제 #5
0
 public void SetId()
 {
     var id = Guid.NewGuid();
     var testClass = new AutomaticIdGuidClass();
     testClass.Id(id);
     Assert.Equal(id, testClass.Id().Get());
     Assert.True(testClass.IsNew());
     Assert.False(testClass.IsModified());
     Assert.Equal(id, testClass.CustomId);
 }
예제 #6
0
        public void Save()
        {
            var testClass = new AutomaticIdGuidClass();
            var id = testClass.Id();
            testClass.Save();
            Assert.False(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.Equal(id, testClass.Id());
            Assert.True(id == testClass.CustomId);

            var loadedTestClass = Modl<AutomaticIdGuidClass>.Get(id);
            Assert.True(id == loadedTestClass.CustomId);
            Assert.Equal(id, loadedTestClass.Id());
            Assert.True(id == loadedTestClass.CustomId);
            Assert.False(loadedTestClass.IsNew());
            Assert.False(loadedTestClass.IsModified());
            Assert.Throws<InvalidIdException>(() => loadedTestClass.Id(Guid.NewGuid()));
        }