コード例 #1
0
        public void OnPostBuild()
        {
            var before = this.Session.Now();

            var units = new UnitSampleBuilder(this.Session).Build();

            this.Session.Derive(false);

            var after = this.Session.Now();

            Assert.False(units.ExistRequiredBinary);
            Assert.False(units.ExistRequiredString);

            Assert.True(units.ExistRequiredBoolean);
            Assert.True(units.ExistRequiredDateTime);
            Assert.True(units.ExistRequiredDecimal);
            Assert.True(units.ExistRequiredDouble);
            Assert.True(units.ExistRequiredInteger);
            Assert.True(units.ExistRequiredUnique);

            Assert.Equal(false, units.RequiredBoolean);
            Assert.True(units.RequiredDateTime > before && units.RequiredDateTime < after);
            Assert.Equal(0m, units.RequiredDecimal);
            Assert.Equal(0d, units.RequiredDouble);
            Assert.Equal(0, units.RequiredInteger);
            Assert.NotEqual(Guid.Empty, units.RequiredUnique);
        }
コード例 #2
0
        public async Task <IActionResult> Pull([FromBody] TestUnitSamplesParams @params)
        {
            try
            {
                var unitSample = new UnitSamples(this.Session).Extent().First;
                if (unitSample == null)
                {
                    unitSample = new UnitSampleBuilder(this.Session).Build();
                    this.Session.Commit();
                }

                var acls            = new WorkspaceAccessControlLists(this.Session.GetUser());
                var responseBuilder = new PullResponseBuilder(acls, this.TreeService);

                switch (@params.Step)
                {
                case 0:
                    unitSample.RemoveAllorsBinary();
                    unitSample.RemoveAllorsBoolean();
                    unitSample.RemoveAllorsDateTime();
                    unitSample.RemoveAllorsDecimal();
                    unitSample.RemoveAllorsDouble();
                    unitSample.RemoveAllorsInteger();
                    unitSample.RemoveAllorsString();
                    unitSample.RemoveAllorsUnique();

                    break;

                case 1:
                    unitSample.AllorsBinary   = new byte[] { 1, 2, 3 };
                    unitSample.AllorsBoolean  = true;
                    unitSample.AllorsDateTime = new DateTime(1973, 3, 27, 0, 0, 0, DateTimeKind.Utc);
                    unitSample.AllorsDecimal  = 12.34m;
                    unitSample.AllorsDouble   = 123d;
                    unitSample.AllorsInteger  = 1000;
                    unitSample.AllorsString   = "a string";
                    unitSample.AllorsUnique   = new Guid("2946CF37-71BE-4681-8FE6-D0024D59BEFF");

                    break;
                }

                this.Session.Commit();

                responseBuilder.AddObject("unitSample", unitSample);
                var pullResponse = responseBuilder.Build();

                return(this.Ok(pullResponse));
            }
            catch (Exception e)
            {
                return(this.BadRequest(e.Message));
            }
        }
コード例 #3
0
        public ActionResult Pull(int step)
        {
            try
            {
                var unitSample = new UnitSamples(this.AllorsSession).Extent().First;
                if (unitSample == null)
                {
                    unitSample = new UnitSampleBuilder(this.AllorsSession).Build();
                    this.AllorsSession.Commit();
                }

                var responseBuilder = new PullResponseBuilder(this.AllorsUser);

                switch (step)
                {
                case 0:
                    unitSample.RemoveAllorsBinary();
                    unitSample.RemoveAllorsBoolean();
                    unitSample.RemoveAllorsDateTime();
                    unitSample.RemoveAllorsDecimal();
                    unitSample.RemoveAllorsDouble();
                    unitSample.RemoveAllorsInteger();
                    unitSample.RemoveAllorsString();
                    unitSample.RemoveAllorsUnique();

                    break;

                case 1:
                    unitSample.AllorsBinary   = new byte[] { 1, 2, 3 };
                    unitSample.AllorsBoolean  = true;
                    unitSample.AllorsDateTime = new DateTime(1973, 3, 27, 0, 0, 0, DateTimeKind.Utc);
                    unitSample.AllorsDecimal  = 12.34m;
                    unitSample.AllorsDouble   = 123d;
                    unitSample.AllorsInteger  = 1000;
                    unitSample.AllorsString   = "a string";
                    unitSample.AllorsUnique   = new Guid("2946CF37-71BE-4681-8FE6-D0024D59BEFF");

                    break;
                }

                this.AllorsSession.Commit();

                responseBuilder.AddObject("unitSample", unitSample);

                return(this.JsonSuccess(responseBuilder.Build()));
            }
            catch (Exception e)
            {
                return(this.JsonError(e.Message));
            }
        }