public void Index_SetsDefaults_WhenCreated() { var sut = new Index(); sut.IsClustered.Should().BeFalse(); sut.IsUnique.Should().BeFalse(); }
public static void Model_IsNotValid_WithIndexFieldsThatAreNotThere() { var model = new Model("Test"); var idx = new Index(); idx.Fields.Add(new IndexField("IDX_Field")); model.Indexes.Add(idx); var sut = new ModelValidator(); var result = sut.TestValidate(model); result.ShouldHaveValidationErrorFor(m => m.Indexes); }
public async Task Index_Serialization() { var sut = new Index(); sut.Fields.Add(new IndexField("Field1") { Sort = ListSortDirection.Descending }); var json = sut.ToJson(); await Verifier.VerifyJson(json); var actual = json.FromJson <Index>(); actual.Should().BeEquivalentTo(sut); }
public void Json_Serialization_ProducesEquivalentModule() { var module = new Module("Jbssa", "SecurityPortal"); var model = new Model("Application"); model.MakeEntity(); model.Fields.Add(new Field("Name") { DataType = DataTypes.String, MaxLength = 100, Nullable = false, BusinessKey = true }); model.Fields.Add(new Field("Description") { MaxLength = 1000 }); model.Fields.Add(new Field("IsActive") { DataType = DataTypes.Bool, Default = "true", Nullable = false }); module.Models.Add(model); var index = new Index() { IsUnique = true }; index.Fields.Add(new IndexField("Name")); model.Indexes.Add(index); var relationship = new Relationship() { PrincipalModel = new Name("Application"), PrincipalType = RelationshipTypes.One, DependantModel = new Name("Module"), DependantType = RelationshipTypes.Many }; relationship.PrincipalFields.Add(new Name("Id")); relationship.DependantFields.Add(new Name("ApplicationId")); model.Relationships.Add(relationship); module .ToJson() .FromJson <Module>() .Should() .BeEquivalentTo(module); }