GetErrors() public method

public GetErrors ( System.Guid instanceId ) : IList
instanceId System.Guid
return IList
Exemplo n.º 1
0
        public void ResourceModel_GetErrors_ErrorsForInstance()
        {
            //------------Setup for test--------------------------
            var instanceID = Guid.NewGuid();

            var err1 = new Mock<IErrorInfo>();
            err1.Setup(e => e.InstanceID).Returns(instanceID);
            var err2 = new Mock<IErrorInfo>();
            err2.Setup(e => e.InstanceID).Returns(Guid.NewGuid());
            var model = new ResourceModel(new Mock<IEnvironmentModel>().Object, new Mock<IEventAggregator>().Object);
            model.AddError(err1.Object);
            model.AddError(err2.Object);

            //------------Execute Test---------------------------
            var errors = model.GetErrors(instanceID);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual(instanceID, errors[0].InstanceID);
        }
Exemplo n.º 2
0
        public void ResourceModel_RemoveError_ErrorIsNotFound_DoesNothing()
        {
            var instanceID = Guid.NewGuid();

            IErrorInfo err1 = new ErrorInfo
            {
                InstanceID = instanceID,
                ErrorType = ErrorType.Critical,
                FixType = FixType.ReloadMapping
            };

            IErrorInfo err2 = new ErrorInfo
            {
                InstanceID = instanceID,
                ErrorType = ErrorType.Warning,
                FixType = FixType.ReloadMapping
            };
            var model = new ResourceModel(new Mock<IEnvironmentModel>().Object, new Mock<IEventAggregator>().Object);
            model.AddError(err1);
            model.AddError(err2);

            //------------Execute Test---------------------------
            model.RemoveError(new ErrorInfo
            {
                InstanceID = instanceID,
                ErrorType = ErrorType.None,
                FixType = FixType.Delete
            });

            //------------Assert Results-------------------------
            var errors = model.GetErrors(instanceID);

            Assert.AreEqual(2, errors.Count);
            Assert.AreSame(err1, errors[0]);
            Assert.AreSame(err2, errors[1]);
        }
Exemplo n.º 3
0
        public void ResourceModel_Environment_DesignValidationService_WiredUp()
        {
            var eventPublisher = new EventPublisher();

            var environmentID = Guid.NewGuid();
            var environment = new Mock<IEnvironmentModel>();
            environment.Setup(e => e.ID).Returns(environmentID);
            environment.Setup(e => e.Connection.ServerEvents).Returns(eventPublisher);

            var instanceID = Guid.NewGuid();
            var model = new ResourceModel(environment.Object, new Mock<IEventAggregator>().Object);

            var errors = model.GetErrors(instanceID);
            Assert.AreEqual(0, errors.Count);

            var err = new ErrorInfo
            {
                InstanceID = instanceID,
            };

            var memo = new DesignValidationMemo
            {
                InstanceID = environmentID,
                Errors = new List<IErrorInfo>
                {
                    err
                }
            };

            //------------Execute Test---------------------------
            eventPublisher.Publish(memo);

            //------------Assert Results-------------------------
            errors = model.GetErrors(instanceID);
            Assert.AreEqual(1, errors.Count);
            Assert.AreSame(err, errors[0]);
        }