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); }
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); }
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); }
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())); }
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())); }