Example #1
0
        public void VerifyThatValidatePocoPropertiesAddsScaleValueDefinitionError()
        {
            Assert.DoesNotThrowAsync(async() => await this.session.Object.Open());

            var ratioScale = new RatioScale(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                            this.session.Object.Credentials.Uri);
            var scaleValueDefinition = new ScaleValueDefinition(Guid.NewGuid(), this.session.Object.Assembler.Cache,
                                                                this.session.Object.Credentials.Uri);

            ratioScale.ValueDefinition.Add(scaleValueDefinition);

            this.siteReferenceDataLibrary.Scale.Add(ratioScale);

            scaleValueDefinition.ValidatePoco();

            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(scaleValueDefinition.Iid, null),
                                                       new Lazy <Thing>(() => scaleValueDefinition));

            this.viewModel.BindPocoErrors();

            Assert.That(this.viewModel.Errors.Any(e => e.Error.Contains("The property Name is null or empty")));
            Assert.That(this.viewModel.Errors.Any(e => e.Error.Contains("The property ShortName is null or empty")));

            Assert.DoesNotThrow(() => this.viewModel.FixCommand.Execute(null));

            Assert.AreEqual(0, this.viewModel.Errors.Count(e => e.Error.Contains("The property Name is null or empty")));
            Assert.AreEqual(0, this.viewModel.Errors.Count(e => e.Error.Contains("The property ShortName is null or empty")));

            Assert.DoesNotThrowAsync(async() => await this.session.Object.Close());
        }