Ejemplo n.º 1
0
        public void Configure_SequenceStorage_When_ObjectSpace_Commits(Type objectViewType)
        {
            Tracing.Close();
            var testObserver = new TestTracing().WhenException().Test();

            Tracing.Initialize();
            using var application = NewApplication(handleExceptions: false);
            ((WinApplication)application).CustomHandleException += (_, args) => args.Handled = true;
            SequenceGeneratorModule(application);
            SetSequences(application);
            var modelClass      = application.Model.BOModel.GetClass(typeof(SequenceStorage));
            var viewId          = objectViewType == typeof(DetailView) ? modelClass.DefaultDetailView.Id : modelClass.DefaultListView.Id;
            var compositeView   = application.NewView(application.FindModelView(viewId));
            var sequenceStorage = compositeView.ObjectSpace.GetObjectsQuery <SequenceStorage>().First();

            sequenceStorage.Member = null;
            compositeView.ObjectSpace.CommitChanges();

            testObserver.Items.First().Message.ShouldContain("Cannot find the '' property within the ");
            compositeView.ObjectSpace.CommitChanges();
            // testObserver.Items.Count.ShouldBe(2);
            testObserver.Items.Last().Message.ShouldContain("Cannot find the '' property within the ");
            sequenceStorage.Member = new ObjectString(nameof(TestObject.SequentialNumber));
            compositeView.ObjectSpace.CommitChanges();
            // testObserver.Items.Count.ShouldBe(2);
        }
Ejemplo n.º 2
0
        public void Configure_SequencStorage_When_ObjectSpace_Commits(Type objectViewType)
        {
            Tracing.Close();
            var testObserver = new TestTracing().WhenException().Test();

            Tracing.Initialize();
            using (var application = NewApplication(Platform.Web)){
                SequenceGeneratorModule(nameof(Configure_SequencStorage_When_ObjectSpace_Commits), application);
                SetSequences(application);
                var modelClass      = application.Model.BOModel.GetClass(typeof(SequenceStorage));
                var viewId          = objectViewType == typeof(DetailView) ? modelClass.DefaultDetailView.Id : modelClass.DefaultListView.Id;
                var compositeView   = application.NewView(application.FindModelView(viewId));
                var sequenceStorage = compositeView.ObjectSpace.GetObjectsQuery <SequenceStorage>().First();
                sequenceStorage.Member = null;
                compositeView.ObjectSpace.CommitChanges();
                testObserver.Items.Count.ShouldBe(1);
                testObserver.Items.First().Message.ShouldContain("Cannot find the '' property within the ");
                compositeView.ObjectSpace.CommitChanges();
                testObserver.Items.Count.ShouldBe(2);
                testObserver.Items.Last().Message.ShouldContain("Cannot find the '' property within the ");
                sequenceStorage.Member = new ObjectMember()
                {
                    Name = nameof(TestObject.SequentialNumber)
                };
                compositeView.ObjectSpace.CommitChanges();
                testObserver.Items.Count.ShouldBe(2);
            }
        }
Ejemplo n.º 3
0
        public virtual void SetUp()
        {
            Tracing.Close();
            Tracing.Initialize("", "0");
            CaptionHelper.Setup(null);
            if (NeedHardResetTypesInfo)
            {
                typesInfo = CreateTypesInfo();
                typesInfo.LoadTypesForTestFixture(this, assemblyName => IsRequiredAssembly(assemblyName.Name));
            }
            testContext      = CreateTestContext(typesInfo);
            modelApplication = (IModelApplication)testContext.GetModelApplicationCreator().CreateModelApplication();
            modelApplication.
            AddLayer(testContext, "AutoGeneratedLayer").
            AddLayer(testContext, "DiffLayer").
            SetEditorDescriptors(testContext);
            List <IXafResourceLocalizer> localizers = new List <IXafResourceLocalizer>();

            AddResourceLocalizers(localizers);
            if (localizers.Count > 0)
            {
                modelApplication.SetLocalizers(localizers);
                CaptionHelper.Setup(modelApplication);
            }
        }