コード例 #1
0
ファイル: CustomIdIntTest.cs プロジェクト: bazer/Modl
        public void SetId()
        {
            var id        = 644564;
            var testClass = new CustomIdIntClass();

            Assert.Equal(0, testClass.CustomId);
            Assert.False(testClass.Id().IsSet);
            testClass.Id(id);
            Assert.True(testClass.Id().IsSet);
            Assert.Equal(id, testClass.Id().Get());
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.Equal(id, testClass.CustomId);

            id        = 747474;
            testClass = new CustomIdIntClass();
            Assert.Equal(0, testClass.CustomId);
            Assert.False(testClass.Id().IsSet);
            testClass.CustomId = id;
            Assert.True(testClass.Id().IsSet);
            Assert.Equal(id, testClass.Id().Get());
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.Equal(id, testClass.CustomId);

            id = 644563434;
            testClass.Id(id.ToString());
            Assert.Equal(id, testClass.CustomId);
            Assert.True(id == testClass.Id());
            Assert.Throws <InvalidIdException>(() => testClass.Id(Guid.NewGuid()));
        }
コード例 #2
0
ファイル: CustomIdIntTest.cs プロジェクト: bazer/Modl
        public void Save()
        {
            var testClass = new CustomIdIntClass();

            Assert.Throws <InvalidIdException>(() => testClass.Save());

            var id = 2472;

            testClass.CustomId = id;
            testClass.Save();

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

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

            Assert.Equal(id, loadedTestClass.CustomId);
            Assert.True(id == loadedTestClass.Id());
            Assert.Equal(id, loadedTestClass.CustomId);
            Assert.False(loadedTestClass.IsNew());
            Assert.False(loadedTestClass.IsModified());
            Assert.Throws <InvalidIdException>(() => loadedTestClass.Id(4544));
            Assert.Throws <InvalidIdException>(() =>
            {
                loadedTestClass.CustomId = 4544;
                loadedTestClass.Save();
            });
        }
コード例 #3
0
ファイル: CustomIdIntTest.cs プロジェクト: bazer/Modl
        public void Delete()
        {
            var testClass = new CustomIdIntClass();

            var id = Guid.NewGuid();
            testClass.CustomId = 1;
            Assert.Throws<NotFoundException>(() => testClass.Delete());

            testClass.Save();
            Assert.False(testClass.IsDeleted());
            testClass.Delete();
            Assert.True(testClass.IsDeleted());
            Assert.Throws<NotFoundException>(() => testClass.Save());
            Assert.Throws<NotFoundException>(() => testClass.Delete());
        }
コード例 #4
0
ファイル: CustomIdIntTest.cs プロジェクト: bazer/Modl
        public void Delete()
        {
            var testClass = new CustomIdIntClass();

            var id = Guid.NewGuid();

            testClass.CustomId = 1;
            Assert.Throws <NotFoundException>(() => testClass.Delete());

            testClass.Save();
            Assert.False(testClass.IsDeleted());
            testClass.Delete();
            Assert.True(testClass.IsDeleted());
            Assert.Throws <NotFoundException>(() => testClass.Save());
            Assert.Throws <NotFoundException>(() => testClass.Delete());
        }
コード例 #5
0
ファイル: CustomIdIntTest.cs プロジェクト: bazer/Modl
        public void CreateNew()
        {
            var testClass = new CustomIdIntClass();
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());

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

            var id = 3433;
            testClass = Modl<CustomIdIntClass>.New(id);
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.True(id == testClass.Id());
            Assert.Equal(id, testClass.CustomId);
        }
コード例 #6
0
ファイル: CustomIdIntTest.cs プロジェクト: bazer/Modl
        public void CreateNew()
        {
            var testClass = new CustomIdIntClass();

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

            testClass = Modl <CustomIdIntClass> .New();

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

            var id = 3433;

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

            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.True(id == testClass.Id());
            Assert.Equal(id, testClass.CustomId);
        }
コード例 #7
0
ファイル: CustomIdIntTest.cs プロジェクト: bazer/Modl
        public void SetId()
        {
            var id = 644564;
            var testClass = new CustomIdIntClass();
            Assert.Equal(0, testClass.CustomId);
            Assert.False(testClass.Id().IsSet);
            testClass.Id(id);
            Assert.True(testClass.Id().IsSet);
            Assert.Equal(id, testClass.Id().Get());
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.Equal(id, testClass.CustomId);

            id = 747474;
            testClass = new CustomIdIntClass();
            Assert.Equal(0, testClass.CustomId);
            Assert.False(testClass.Id().IsSet);
            testClass.CustomId = id;
            Assert.True(testClass.Id().IsSet);
            Assert.Equal(id, testClass.Id().Get());
            Assert.True(testClass.IsNew());
            Assert.False(testClass.IsModified());
            Assert.Equal(id, testClass.CustomId);

            id = 644563434;
            testClass.Id(id.ToString());
            Assert.Equal(id, testClass.CustomId);
            Assert.True(id == testClass.Id());
            Assert.Throws<InvalidIdException>(() => testClass.Id(Guid.NewGuid()));
        }
コード例 #8
0
ファイル: CustomIdIntTest.cs プロジェクト: bazer/Modl
        public void Save()
        {
            var testClass = new CustomIdIntClass();
            Assert.Throws<InvalidIdException>(() => testClass.Save());

            var id = 2472;
            testClass.CustomId = id;
            testClass.Save();

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

            var loadedTestClass = Modl<CustomIdIntClass>.Get(id);
            Assert.Equal(id, loadedTestClass.CustomId);
            Assert.True(id == loadedTestClass.Id());
            Assert.Equal(id, loadedTestClass.CustomId);
            Assert.False(loadedTestClass.IsNew());
            Assert.False(loadedTestClass.IsModified());
            Assert.Throws<InvalidIdException>(() => loadedTestClass.Id(4544));
            Assert.Throws<InvalidIdException>(() =>
            {
                loadedTestClass.CustomId = 4544;
                loadedTestClass.Save();
            });
        }