Ejemplo n.º 1
0
        public void ExtractData_EmptyMethodsAreIgnored()
        {
            var reader = new EntityBehaviourReader();

            var entity = reader.ExtractData(FileText);

            entity.EntityBehaviours.ShouldNotContain(m => string.IsNullOrEmpty(m.Expression));
        }
Ejemplo n.º 2
0
        public void ExtractData_HasInitialize()
        {
            var reader = new EntityBehaviourReader();

            var entity = reader.ExtractData(FileText);

            entity.EntityBehaviours.ShouldContain(m => m.Name.Equals("Initialize"));
        }
Ejemplo n.º 3
0
        public void ExtractData_NamespaceMatch()
        {
            var reader = new EntityBehaviourReader();

            var entity = reader.ExtractData(FileText);

            entity.Namespace.ShouldBe("Omnia.Behaviours.T99.Internal.System.Model");
        }
Ejemplo n.º 4
0
        public void ExtractData_Successfully()
        {
            var reader = new EntityBehaviourReader();

            var entity = reader.ExtractData(FileText);

            entity.EntityBehaviours.ShouldNotBeNull();
            entity.EntityBehaviours.Count.ShouldBe(8);
        }
Ejemplo n.º 5
0
        public void ExtractData_ValidExpression()
        {
            var reader = new EntityBehaviourReader();

            var initialize = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Type == Omnia.CLI.Commands.Model.Apply.Data.Server.EntityBehaviourType.Initialize);

            initialize.Expression.ShouldBe("this._name = \"Hello World!\";");
        }
Ejemplo n.º 6
0
        public void ExtractData_WithBeforeCollectionEntityInitialize_ValidExpression()
        {
            var reader = new EntityBehaviourReader();

            var initialize = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Name.Equals("OnBeforecollectionEntityInitialize"));

            initialize.Expression.ShouldBe("entry._name = \"Child initialized\";");
        }
Ejemplo n.º 7
0
        public void ExtractData_WithFormula_ValidExpression()
        {
            var reader = new EntityBehaviourReader();

            var formula = reader.ExtractData(FileText)
                          .EntityBehaviours
                          .First(m => m.Name.Equals("Getname"));

            formula.Expression.ShouldBe("return \"New Name\";");
        }
Ejemplo n.º 8
0
        public void ExtractData_WithFormula_CorrectAttribute()
        {
            var reader = new EntityBehaviourReader();

            var formula = reader.ExtractData(FileText)
                          .EntityBehaviours
                          .First(m => m.Name.Equals("Getname"));

            formula.Attribute.ShouldBe("name");
        }
Ejemplo n.º 9
0
        public void ExtractData_WithFormula_ValidType()
        {
            var reader = new EntityBehaviourReader();

            var formula = reader.ExtractData(FileText)
                          .EntityBehaviours
                          .First(m => m.Name.Equals("Getname"));

            formula.Type.ShouldBe(Omnia.CLI.Commands.Model.Apply.Data.Server.EntityBehaviourType.Formula);
        }
Ejemplo n.º 10
0
        public void ExtractData_WithPropertyChange_CorrectAttribute()
        {
            var reader = new EntityBehaviourReader();

            var initialize = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Name.Equals("On_codePropertyChange"));

            initialize.Attribute.ShouldBe("_code");
        }
Ejemplo n.º 11
0
        public void ExtractData_WithPropertyChange_ValidType()
        {
            var reader = new EntityBehaviourReader();

            var initialize = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Name.Equals("On_codePropertyChange"));

            initialize.Type.ShouldBe(Omnia.CLI.Commands.Model.Apply.Data.Server.EntityBehaviourType.Action);
        }
Ejemplo n.º 12
0
        public void ExtractData_UsesCommentDescription()
        {
            var reader = new EntityBehaviourReader();

            var initialize = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Type == Omnia.CLI.Commands.Model.Apply.Data.Server.EntityBehaviourType.Initialize);

            initialize.Description.ShouldBe($"Set the name to:{Environment.NewLine}Hello World!");
        }
Ejemplo n.º 13
0
        public void ExtractData_WithBeforeCollectionEntityInitialize_CorrectAttribute()
        {
            var reader = new EntityBehaviourReader();

            var initialize = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Name.Equals("OnBeforecollectionEntityInitialize"));

            initialize.Attribute.ShouldBe("collection");
        }
Ejemplo n.º 14
0
        public void ExtractData_WithBeforeCollectionEntityInitialize_ValidType()
        {
            var reader = new EntityBehaviourReader();

            var initialize = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Name.Equals("OnBeforecollectionEntityInitialize"));

            initialize.Type.ShouldBe(Omnia.CLI.Commands.Model.Apply.Data.Server.EntityBehaviourType.BeforeCollectionEntityInitialize);
        }
Ejemplo n.º 15
0
        public void ExtractData_UsesCommentName()
        {
            var reader = new EntityBehaviourReader();

            var initialize = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Type == Omnia.CLI.Commands.Model.Apply.Data.Server.EntityBehaviourType.Initialize);

            initialize.Name.ShouldBe("Initialize");
        }
Ejemplo n.º 16
0
        public void ExtractData_WithAfterSave_ValidExpression()
        {
            var reader = new EntityBehaviourReader();

            var afterSave = reader.ExtractData(FileText)
                            .EntityBehaviours
                            .First(m => m.Name.Equals("OnAfterSave"));

            afterSave.Expression.ShouldBe("return await Task.FromResult(AfterSaveMessage.Empty);");
        }
Ejemplo n.º 17
0
        public void ExtractData_SuccessfullyExtractUsings()
        {
            var reader = new EntityBehaviourReader();

            var entity = reader.ExtractData(FileText);

            entity.Usings.ShouldNotBeNull();
            entity.Usings.Count.ShouldBe(1);
            entity.Usings.Single().ShouldBe("MyCompany.CustomDll");
        }
Ejemplo n.º 18
0
        public void ExtractData_WithAfterSave_ValidType()
        {
            var reader = new EntityBehaviourReader();

            var afterSave = reader.ExtractData(FileText)
                            .EntityBehaviours
                            .First(m => m.Name.Equals("OnAfterSave"));

            afterSave.Type.ShouldBe(Omnia.CLI.Commands.Model.Apply.Data.Server.EntityBehaviourType.AfterSave);
        }
Ejemplo n.º 19
0
        public void ExtractData_WithBeforeSave_ValidExpression()
        {
            var reader = new EntityBehaviourReader();

            var beforeSave = reader.ExtractData(FileText)
                             .EntityBehaviours
                             .First(m => m.Name.Equals("OnBeforeSave"));

            beforeSave.Expression.ShouldBe("_name = \"tst\";");
        }
Ejemplo n.º 20
0
        public void ExtractData_WithBeforeChange_ValidExpression()
        {
            var reader = new EntityBehaviourReader();

            var beforeChange = reader.ExtractData(FileText)
                               .EntityBehaviours
                               .First(m => m.Name.Equals("OnBeforeUpdate"));

            beforeChange.Expression.ShouldBe("this._name = \"Hello World 2!\";");
        }
Ejemplo n.º 21
0
        public void ExtractData_WithBeforeChange_ValidType()
        {
            var reader = new EntityBehaviourReader();

            var beforeChange = reader.ExtractData(FileText)
                               .EntityBehaviours
                               .First(m => m.Name.Equals("OnBeforeUpdate"));

            beforeChange.Type.ShouldBe(Omnia.CLI.Commands.Model.Apply.Data.Server.EntityBehaviourType.BeforeChange);
        }
Ejemplo n.º 22
0
        public void ExtractData_WithAfterChange_ValidExpression()
        {
            var reader = new EntityBehaviourReader();

            var afterChange = reader.ExtractData(FileText)
                              .EntityBehaviours
                              .First(m => m.Name.Equals("OnAfterUpdate"));

            afterChange.Expression.ShouldBe(@"this._name = ""Hello World 3!"";
            this._name = ""Hello World 4!"";");
        }