Exemple #1
0
        public void Constructor_MessageAndInnerException_MessageAndInnerExcetion()
        {
            var target = new MutationException("1", new Exception("2"));

            Assert.AreEqual("1", target.Message);
            Assert.AreEqual("2", target.InnerException.Message);
        }
Exemple #2
0
        public void Constructor_MutationAndMessageAndInnerException_MutationAndMessageAndInnerExcetion()
        {
            var target = new MutationException(MockRepository.GenerateMock <IMutation>(), "1", new Exception("2"));

            Assert.IsNotNull(target.Mutation);
            Assert.AreEqual(target.Mutation.GetType().Name + ": 1", target.Message);
            Assert.AreEqual("2", target.InnerException.Message);
        }
        public void Constructor_MutationAndMessageAndInnerException_MutationAndMessageAndInnerExcetion()
        {
            var target = new MutationException(Substitute.For <IMutation>(), "1", new Exception("2"));

            Assert.IsNotNull(target.Mutation);
            Assert.AreEqual(target.Mutation.GetType().Name + ": 1", target.Message);
            Assert.AreEqual("2", target.InnerException.Message);
        }
Exemple #4
0
        public void GetObjectData_InfoAndContext_Property()
        {
            var propertyValue     = MockRepository.GenerateMock <IMutation>();
            var target            = new MutationException(propertyValue, "1");
            var serializationInfo = new SerializationInfo(typeof(int), MockRepository.GenerateMock <IFormatterConverter>());

            target.GetObjectData(serializationInfo, new StreamingContext());

            Assert.AreEqual(propertyValue, serializationInfo.GetValue("Mutation", typeof(IMutation)));
        }
Exemple #5
0
        /// <summary>
        /// Process the <see cref="ConfigurationSetStableRequest"/>
        /// </summary>
        /// <param name="request">The request</param>
        private void OnConfigurationSetStable(ConfigurationSetStableRequest request)
        {
            try
            {
                using (var ds = this.GetContext())
                {
                    var configuration = ds.Configurations.FirstOrDefault(r => r.Id == request.Id);
                    if (configuration == null)
                    {
                        this.Sender.Tell(CrudActionResponse <Configuration> .Error(new EntityNotFoundException(), null));
                        return;
                    }

                    if (configuration.State != EnConfigurationState.Active)
                    {
                        this.Sender.Tell(
                            CrudActionResponse <Configuration> .Error(
                                new Exception("Only active configurations can be marked as stable"),
                                null));
                        return;
                    }

                    if (configuration.IsStable != request.IsStable)
                    {
                        var error             = new ErrorDescription("isStable", "The value is not changed");
                        var mutationException = new MutationException(error);
                        this.Sender.Tell(CrudActionResponse <Configuration> .Error(mutationException, null));
                        return;
                    }

                    configuration.IsStable = request.IsStable;
                    ds.SaveChanges();
                    this.Sender.Tell(CrudActionResponse <Configuration> .Success(configuration, null));
                }
            }
            catch (Exception exception)
            {
                this.Sender.Tell(CrudActionResponse <Configuration> .Error(exception, null));
            }
        }
Exemple #6
0
        public void Constructor_Message_Message()
        {
            var target = new MutationException("1");

            Assert.AreEqual("1", target.Message);
        }
Exemple #7
0
        public void Constructor_NoArgs_DefaultValue()
        {
            var target = new MutationException();

            Assert.IsTrue(target.Message.Contains("MutationException"));
        }