Example #1
0
		public MazeImagePoint(string line)
		{
			string[] parameters = line.Split(' ');
			X = int.Parse(parameters[0]);
			Y = int.Parse(parameters[1]);
			Operation = (Operation)int.Parse(parameters[2]);
		}
        public void RunOperationAsync(Operation op)
        {
            if (op == null)
                throw new ArgumentNullException();

            SetOperationInternal(op, false);
        }
Example #3
0
        Graph ProcessOperation(Graph initGraph, Operation op, Stack<Word> opStack)
        {
            // create base graph if not done already.
            if(initGraph == null){
                //start of our graph
                initGraph = Graph.CreateNewGraph(opStack.Pop());
            }

            //if kleene operation, do it here.
            if (op.Mapping == OperationType.Kleene) {
                initGraph = initGraph.Kleene ();
            }

            //now process each operation
            while(opStack.Count != 0){
                //get next letter to work with.
                var wordToAdd = opStack.Pop();

                //depending on the mapped type, do operation on graph
                //with the new letter.
                if(op.Mapping == OperationType.Concat)
                    initGraph = initGraph.Concat(wordToAdd);
                else if(op.Mapping == OperationType.Union)
                    initGraph = initGraph.Union(wordToAdd);
            }

            //return the created graph.
            return initGraph;
        }
Example #4
0
        void IJob.Execute(IJobContext context, Operation operation)
        {
            // Construct Notification text
            string body = "Einsatz:\r\n";
            body += "Zeitstempel: " + operation.Timestamp.ToString() + "\r\n";
            body += "Stichwort: " + operation.Keywords.Keyword + "\r\n";
            body += "Meldebild: " + operation.Picture + "\r\n";
            body += "Einsatznr: " + operation.OperationNumber + "\r\n";
            body += "Hinweis: " + operation.Comment + "\r\n";
            body += "Mitteiler: " + operation.Messenger + "\r\n";
            body += "Einsatzort: " + operation.Einsatzort.Location + "\r\n";
            body += "Straße: " + operation.Einsatzort.Street + " " + operation.Einsatzort.StreetNumber + "\r\n";
            body += "Ort: " + operation.Einsatzort.ZipCode + " " + operation.Einsatzort.City + "\r\n";
            body += "Objekt: " + operation.Einsatzort.Property + "\r\n";

            ProwlNotification notifi = new ProwlNotification();
            notifi.Priority = ProwlNotificationPriority.Emergency;
            notifi.Event = "Feuerwehr Einsatz";
            notifi.Description = body;

            //Send the Message
            try
            {
                _client.PostNotification(notifi);
            }
            catch (Exception ex)
            {
                Logger.Instance.LogFormat(LogType.Error, this, "An error occurred while sending the Prowl Messages.", ex);
            }
        }
Example #5
0
 /// <returns>T- should die</returns>
 protected bool oper(ref int res, int a, int b, Operation op)
 {
     switch (op)
     {
         case Operation.ADD:
             res = a + b;
             if (res >= coreSize) res -= coreSize;
             break;
         case Operation.SUB:
             res = a - b;
             if (res < 0) res += coreSize;
             break;
         case Operation.MUL:
             res = a * b;
             res %= coreSize;
             break;
         case Operation.MOD:
             if (b == 0) return true;
             res = a % b;
             break;
         case Operation.DIV:
             if (b == 0) return true;
             res = a / b;
             break;
         default:
             throw new InvalidOperationException("Unknown instruction");
     }
     return false;
 }
Example #6
0
        public void OperationResult()
        {
            var operation = Operation.Create <int>(_methods.ReturnInt);

            Assert.AreEqual(operation.Result, 1);
            Assert.IsTrue(operation.Succeeded);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OperationValidationException" /> class.
        /// </summary>
        /// <param name="operation">
        /// The operation whose contents is invalid.
        /// </param>
        /// <param name="message">
        /// The message that describes the error.
        /// </param>
        public OperationValidationException([NotNull] Operation operation, [NotNull] string message)
            : base(FormatMessage(operation, message))
        {
            Guard.NotNull(operation, nameof(operation));

            Operation = operation;
        }
        public void Process(int sender, int receiver, Operation operation, object data)
        {
            IFrontCommand command = this.GetCommand(receiver);

            command.Initialize(sender, data, operation);
            command.Process();
        }
Example #9
0
        private void LoadOperationRouteImage(Operation operation)
        {
            string fileUrl = string.Format("~/Cache/RouteImages/{0}.png", Regex.Replace(operation.OperationNumber, "[^a-zA-Z0-9]", "").ToString());
            string filePath = MapPath(fileUrl);

            if (!File.Exists(filePath))
            {
                string directory = Path.GetDirectoryName(filePath);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                // Write the route image
                if (operation.RouteImage != null && operation.RouteImage.Length > 0)
                {
                    File.WriteAllBytes(filePath, operation.RouteImage);
                }
                else
                {
                    // Write empty file to designate that no image is available
                    File.WriteAllText(filePath, "");
                }
            }

            // If it is a zero-sized file, then no route image existed (see above).
            FileInfo fileInfo = new FileInfo(filePath);
            if (fileInfo.Length == 0L)
            {
                return;
            }

            this.imgRouteImage.ImageUrl = fileUrl;
        }
Example #10
0
 public static Interval Calculate(Operation operation, Interval a, Interval b)
 {
     Interval result = new Interval();
     switch (operation)
     {
         case Operation.Add:
             result.UpperBound = a.UpperBound + b.UpperBound;
             result.LowerBound = a.LowerBound + b.LowerBound;
             break;
         case Operation.Sub:
             result.UpperBound = a.UpperBound - b.LowerBound;
             result.LowerBound = a.LowerBound - b.UpperBound;
             break;
         case Operation.Mul:
             result.UpperBound = Math.Max(Math.Max(a.UpperBound * b.UpperBound, a.UpperBound * b.LowerBound), Math.Max(a.LowerBound * b.UpperBound, a.LowerBound * b.LowerBound));
             result.LowerBound = Math.Min(Math.Min(a.UpperBound * b.UpperBound, a.UpperBound * b.LowerBound), Math.Min(a.LowerBound * b.UpperBound, a.LowerBound * b.LowerBound));
             break;
         case Operation.Div:
             if (b.UpperBound != 0 && b.LowerBound != 0)
             {
                 result.UpperBound = Math.Max(Math.Max(a.UpperBound / b.UpperBound, a.UpperBound / b.LowerBound), Math.Max(a.LowerBound / b.UpperBound, a.LowerBound / b.LowerBound));
                 result.LowerBound = Math.Min(Math.Min(a.UpperBound / b.UpperBound, a.UpperBound / b.LowerBound), Math.Min(a.LowerBound / b.UpperBound, a.LowerBound / b.LowerBound));
             }
             break;
         default:
             break;
     }
     return result;
 }
        private void PrintFaxes(IJobContext context, Operation operation)
        {
            if (!context.Parameters.ContainsKey("ArchivedFilePath") || !context.Parameters.ContainsKey("ImagePath"))
            {
                Logger.Instance.LogFormat(LogType.Trace, this, Resources.NoPrintingPossible);
                return;
            }

            System.IO.FileInfo sourceImageFile = new System.IO.FileInfo((string)context.Parameters["ImagePath"]);
            if (!sourceImageFile.Exists)
            {
                Logger.Instance.LogFormat(LogType.Error, this, Resources.FileNotFound, sourceImageFile.FullName);
                return;
            }

            // Grab all created files to print
            string imagePath = (string)context.Parameters["ImagePath"];

            foreach (string queueName in _settings.GetSetting("AlarmSourcePrinterJob", "PrintingQueueNames").GetStringArray())
            {
                var queues = _settings.GetSetting(SettingKeys.PrintingQueuesConfiguration).GetValue<PrintingQueuesConfiguration>();
                PrintingQueue pq = queues.GetPrintingQueue(queueName);
                if (pq == null || !pq.IsEnabled)
                {
                    continue;
                }

                PrintFaxTask task = new PrintFaxTask();
                task.ImagePath = imagePath;
                task.Print(pq);
            }
        }
        public CalcOperation(double a, double b, Operation op)
        {
            A = a;
            B = b;
            Operation = op;

            double result;
            switch (op) {
                case Operation.Addition:
                    result = a + b;
                    break;
                case Operation.Subtraction:
                    result = a - b;
                    break;
                case Operation.Multiplication:
                    result = a * b;
                    break;
                case Operation.Division:
                    result = b == 0
                        ? 0
                        : a / b;
                    break;
                case Operation.Modulo:
                    result = a % b;
                    break;
                default:
                    result = 0;
                    break;
            }
            Result = result;
        }
Example #13
0
        /// <summary>
        /// Creates a new <see cref="PropertyFilter"/>
        /// </summary>
        /// <param name="targetValue">The value against which log events are compared</param>
        /// <param name="operation">The operation used by this <see cref="PropertyFilter" /></param>
        /// <param name="propertyReader">The <see cref="PropertyReader"/> used by this <see cref="PropertyFilter"/></param>
        /// <param name="defaultEvaluation">The default evaluation of the filter in the event of a failure to read the property</param>
        public PropertyFilter(string targetValue, Operation operation, PropertyReader propertyReader, bool defaultEvaluation)
        {
            if (null == propertyReader)
                throw new ArgumentNullException("propertyReader");

            Initialize(targetValue, operation, propertyReader, defaultEvaluation);
        }
        void IJob.Execute(IJobContext context, Operation operation)
        {
            if (context.Phase != JobPhase.AfterOperationStored)
            {
                return;
            }

            if (_configuration.AMExportEnabled)
            {
                try
                {
                    ExportAlarmMonitorFile(operation);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ExportToAMFailed);
                    Logger.Instance.LogException(this, ex);
                }
            }

            if (_configuration.EvaExportEnabled)
            {
                try
                {
                    ExportEvaFile(operation);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ExportToEVAFailed);
                    Logger.Instance.LogException(this, ex);
                }
            }
        }
Example #15
0
        void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
        {
            // Only print if we don't have already (verrrrrrrrrrrry helpful during debugging, but also a sanity-check)
            if (CheckIsOperationAlreadyPrinted(operation, true))
            {
                return;
            }

            PrintQueue printQueue = _printQueue.Value;
            // If printing is not possible (an error occurred because the print server is not available etc.).
            if (printQueue == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, "Cannot print job because the configured printer seems not available! Check log entries.");
                return;
            }

            // We need to wait for a bit to let the UI "catch a breath".
            // Otherwise, if printing immediately, it may have side-effects that parts of the visual aren't visible (bindings not updated etc.).
            Thread.Sleep(_configuration.WaitInterval);

            PrintDialog dialog = new PrintDialog();
            dialog.PrintQueue = printQueue;
            dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
            dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
            dialog.PrintTicket.CopyCount = _configuration.CopyCount;

            FrameworkElement visual = operationViewer.Visual;
            // Measure and arrange the visual before printing otherwise it looks unpredictably weird and may not fit on the page
            visual.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
            visual.Arrange(new Rect(new Point(0, 0), visual.DesiredSize));

            dialog.PrintVisual(visual, "New alarm " + operation.OperationNumber);
        }
Example #16
0
        public void CreateBindFailure()
        {
            var operation = Operation.CreateBind(() => Operation.Fail("An Error Occured"));

            Assert.IsFalse(operation.Succeeded);
            Assert.AreEqual("An Error Occured", operation.Message);
        }
 void IOperationViewer.OnNewOperation(Operation operation)
 {
     foreach (IUIWidget uiWidget in _WidgetManager.Widgets)
     {
         uiWidget.OnOperationChange(operation);
     }
 }
Example #18
0
 public PacketReader(byte[] pBuffer, int nSize)
     : base(new MemoryStream(pBuffer, 0, nSize, false, true))
 {
     base.BaseStream.Position = 8;
     Opcode = (Operation)base.ReadUInt16();
     base.ReadByte();
 }
 public CommandLineOptions(
     Operation operation,
     ImmutableArray<string[]> preprocessorConfigurations,
     ImmutableArray<string> copyrightHeader,
     ImmutableDictionary<string, bool> ruleMap,
     ImmutableArray<string> formatTargets,
     ImmutableArray<string> fileNames,
     string language,
     bool allowTables,
     bool verbose,
     bool formatFiles,
     bool verifyFiles)
 {
     Operation = operation;
     PreprocessorConfigurations = preprocessorConfigurations;
     CopyrightHeader = copyrightHeader;
     RuleMap = ruleMap;
     FileNames = fileNames;
     FormatTargets = formatTargets;
     Language = language;
     AllowTables = allowTables;
     Verbose = verbose;
     FormatFiles = formatFiles;
     VerifyFiles = verifyFiles;
 }
Example #20
0
 void IJob.DoJob(Operation einsatz)
 {
     // TODO: This string contains CustomData. When actually using this job this should be revised to NOT use any custom data (or make it extensible)!
     string text = "Einsatz:%20" + SmsJob.PrepareString(einsatz.City.Substring(0, einsatz.City.IndexOf(" ", StringComparison.Ordinal))) + "%20" + SmsJob.PrepareString((string)einsatz.CustomData["Picture"]) + "%20" + SmsJob.PrepareString(einsatz.Comment) + "%20Strasse:%20" + SmsJob.PrepareString(einsatz.Street);
     foreach (string number in this.numbers)
     {
         try
         {
             HttpWebRequest msg = (HttpWebRequest)System.Net.WebRequest.Create(new Uri("http://gateway.sms77.de/?u=" + this.username + "&p=" + this.password + "&to=" + number + "&text=" + text + "&type=basicplus"));
             HttpWebResponse resp = (HttpWebResponse)msg.GetResponse();
             Stream resp_steam = resp.GetResponseStream();
             using (StreamReader streamreader = new StreamReader(resp_steam, Encoding.UTF8))
             {
                 string response = streamreader.ReadToEnd();
                 if (response != "100")
                 {
                     Logger.Instance.LogFormat(LogType.Warning, this, "Error from sms77! Status code = {0}.", response);
                 }
             }
         }
         catch (Exception ex)
         {
             Logger.Instance.LogFormat(LogType.Error, this, "An error occurred while sending a Sms to '{0}'.", number);
             Logger.Instance.LogException(this, ex);
         }
     }
 }
 public ValueMutationQueueEventProcessor(BlockingCollection<long> blockingQueue, Operation operation, long iterations)
 {
     _blockingQueue = blockingQueue;
     _operation = operation;
     _iterations = iterations;
     _done = false;
 }
Example #22
0
        void IJob.Execute(IJobContext context, Operation operation)
        {
            //Gets the mail-addresses with googlemail.com or gmail.com
            foreach (MailAddressEntryObject recipient in _recipientsEntry)
            {
                if (recipient.Address.Address.EndsWith("@gmail.com") ||
                    recipient.Address.Address.EndsWith("@googlemail.com"))
                {
                    _recipients.Add(recipient.Address.Address);
                }
            }
            string to = String.Join(",", _recipients.ToArray());

            //TODO Fetching Longitude and Latitude!
            Dictionary<String, String> geoCode =
                Helpers.GetGeocodes(operation.Einsatzort.Location + " " + operation.Einsatzort.Street + " " + operation.Einsatzort.StreetNumber);
            String longitude = "0";
            String latitude = "0";
            if (geoCode != null)
            {
                longitude = geoCode[Resources.LONGITUDE];
                latitude = geoCode[Resources.LATITUDE];
            }
            String body = operation.ToString(SettingsManager.Instance.GetSetting("eAlarm", "text").GetString());
            String header = operation.ToString(SettingsManager.Instance.GetSetting("eAlarm", "header").GetString());
            var postParameters = new Dictionary<string, string>
                                     {
                                         {"email", to},
                                         {"header", header},
                                         {"text", body},
                                         {"long", longitude},
                                         {"lat", latitude}
                                     };
            string postData = postParameters.Keys.Aggregate("",
                                                            (current, key) =>
                                                            current +
                                                            (HttpUtility.UrlEncode(key) + "=" +
                                                             HttpUtility.UrlEncode(postParameters[key]) + "&"));

            byte[] data = Encoding.UTF8.GetBytes(postData);
            webRequest.ContentLength = data.Length;

            Stream requestStream = webRequest.GetRequestStream();
            var webResponse = (HttpWebResponse)webRequest.GetResponse();
            Stream responseStream = webResponse.GetResponseStream();

            requestStream.Write(data, 0, data.Length);
            requestStream.Close();

            if (responseStream != null)
            {
                var reader = new StreamReader(responseStream, Encoding.Default);
                string pageContent = reader.ReadToEnd();
                reader.Close();
                responseStream.Close();
                webResponse.Close();

                //TODO Analyzing Response
            }
        }
Example #23
0
        public static new Inform Parse(XmlElement inform)
        {
            if (inform == null)
            {
                throw new Exception("parameter can't be null!");
            }

            string type = string.Empty;
            string operation = string.Empty;

            if (inform.HasAttribute("Type"))
            {
                type = inform.GetAttribute("Type");
            }
            else
            {
                throw new Exception("load hasn't type attribute!");
            }

            if (inform.HasAttribute("Operation"))
            {
                operation = inform.GetAttribute("Operation");
            }
            else
            {
                throw new Exception("parameter hasn't Operation attribute!");
            }

            Operation enumOperation = (Operation)Enum.Parse(typeof(Operation), operation);

            Inform result = new Inform(enumOperation, inform.Name, type, inform.InnerText);

            return result;

        }
Example #24
0
 public OperationRow(int key, String description, Operation op, Boolean on)
 {
     this.Key = key;
     this.Description = description;
     this.Op = op;
     this.On = on;
 }
Example #25
0
 void AddFunction(Operation op, Func<IEnumerable<Int32>> f)
 {
     //Just add it to the dictionary of operations
     functions.Add(op, f);
     //And to the combobox
     operation.Items.Add(op);
 }
Example #26
0
        /// <summary>
        /// Compares to values using the specified operations (this should be one of the <see cref="SupportedOperations"/>)
        /// </summary>
        /// <param name="operation">The type of <see cref="Operation" /> used for the comparison</param>
        /// <param name="value1">The first value in the comparison</param>
        /// <param name="value2">The second value in the comparison</param>
        /// <returns>true or false</returns>
        public bool Compare(Operation operation, object value1, object value2)
        {
            string string1 = (string)value1;
            string string2 = (string)value2;

            switch (operation)
            {
                case Operation.Equals:
                    return string1 == string2;
                case Operation.NotEquals:
                    return string1 != string2;
                case Operation.IsNull:
                    return string1 == null;
                case Operation.IsNotNull:
                    return string1 != null;
                case Operation.Contains:
                    return string1 != null && string2 != null && string1.Contains(string2);
                case Operation.StartsWith:
                    return
                        string1 != null && string2 != null &&
                        string1.StartsWith(string2, StringComparison.CurrentCulture);
                case Operation.EndsWith:
                    return
                        string1 != null && string2 != null && string1.EndsWith(string2, StringComparison.CurrentCulture);
                case Operation.RegexMatch:
                    return GetRegex(string2).IsMatch(string1);
                default:
                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
                                                                      Resources.OperationNotSupported,
                                                                      operation,
                                                                      typeof(StringComparator).FullName,
                                                                      SupportedOperations));
            }
        }
Example #27
0
 public Telegram(int sender, int receiver, Operation operation, dynamic data)
 {
     this._sender = sender;
     this._receiver = receiver;
     this._operation = operation;
     this._data = data;
 }
        public Column GetColumn(string key, ColumnPath columnPath)
        {
            AssertColumnPath(columnPath);

            var op = new Operation<Column>(ClientCounter.READ_FAIL);
            op.Handler = client =>
            {
                try
                {
                    var cosc = client.get(Name, key, columnPath.ToThrift(), ConsistencyLevel.ToThrift());
                    return cosc == null ? null : cosc.Column.ToModel();
                }
                catch (Apache.Cassandra051.NotFoundException ex)
                {
                    op.Error = new NotFoundException("Column Not Found: key: " + key + ", " + columnPath.ToString(), ex);
                }
                return null;
            };

            OperateWithFailover(op);

            if (op.HasError)
                throw op.Error;
            return op.Result;
        }
 void IJob.Execute(IJobContext context, Operation operation)
 {
     if (context.Phase == JobPhase.AfterOperationStored)
     {
         PrintOperation(operation);
     }
 }
Example #30
0
 protected BinaryExpression(Operation operation, Expression left, Expression right, TextPosition position)
     : base(position)
 {
     Operation = operation;
     Left = left;
     Right = right;
 }
Example #31
0
        private void ProcessArithmetic(Operation op)
        {
            var first = Process.EvalStack.Pop();
            var second = Process.EvalStack.Pop();

            var type = first.Type == second.Type ? first.Type : typeof(float);

            var result = new Symbol { Name = Guid.NewGuid().ToString(), Type = type};

            switch (op)
            {
                case Operation.Add:
                    result.Value = first.Value + second.Value;
                    break;
                case Operation.Sub:
                    result.Value = first.Value - second.Value;
                    break;
                case Operation.Mul:
                    result.Value = first.Value * second.Value;
                    break;
                case Operation.Div:
                    result.Value = first.Value / second.Value;
                    break;
            }

            Process.EvalStack.Push(result);
        }
Example #32
0
        /// <summary>
        /// Konstruktor okna warunków początkowych
        /// </summary>
        internal InitialCondition(int _mode=SPDAssets.MAX,InitialConditions condition=null)
        {
            _tooltip = -1;
            InitializeComponent();

            Mode = _mode;
            _selectedOperation = Operation.None;
            ComboBox.ItemsSource = SPDAssets.GetBrushRectangles(Mode,InitialConditions.GetTransformation(Mode));
            ComboBox.SelectedIndex = 0;
            DataContext = this;
            _conditionNames = new List<Tuple<string,Tuple<string,bool> > >();
            _conditions = new Dictionary<Tuple<string, bool>, Func<bool, int, int, bool, InitialConditions>>();
            foreach (var T in new[] {false, true})
            {
                _conditions.Add(new Tuple<string, bool>("Donut", T), InitialConditions.DonutFactory);
                _conditions.Add(new Tuple<string, bool>("Circle", T), InitialConditions.CircleFactory);
                _conditions.Add(new Tuple<string,bool>("Diagonal",T),InitialConditions.DiagonalFactory);
                _conditions.Add(new Tuple<string, bool>("NowakMay", T), InitialConditions.NowakMayFactory);
            }
            _conditionNames.AddRange(
                _conditions.Select(
                    k =>
                        new Tuple<string, Tuple<string, bool>>(k.Value(k.Key.Item2, 1,10,false).Name,
                            new Tuple<string, bool>(k.Key.Item1, k.Key.Item2))));
            ComboBoxCopy.ItemsSource = _conditionNames.Select(s=>s.Item1);
            var D = SPDAssets.GenerateLegend(Legend.Height, Mode, InitialConditions.GetTransformation(Mode));
            D.Stretch = Stretch.Fill;

            Legend.Children.Add(D);
            if (condition != null) Condition = condition;
        }
Example #33
0
        public void OperationSuccess()
        {
            var op1 = Operation.Success();
            var op2 = Operation.Success(1000);

            Assert.IsTrue(op1.Succeeded);
            Assert.IsTrue(op2.Succeeded);
            Assert.AreEqual(1000, op2.Result);
        }
Example #34
0
        public void OperationFail()
        {
            var message = "Evil Error";
            var op1     = Operation.Fail(message);
            var op2     = Operation.Fail <int>(message);

            Assert.AreEqual(message, op1.Message);
            Assert.AreEqual(default(int), op2.Result);
        }
Example #35
0
        public void OperationCreationFailure()
        {
            var operation = Operation.Create(() =>
            {
                throw new Exception("The Error");
            });

            Assert.IsFalse(operation.Succeeded);
            Assert.AreEqual(operation.Message, "The Error");
        }
Example #36
0
        public void CreateBindSuccess()
        {
            var operation = Operation.CreateBind(() =>
            {
                return(Operation.Success(3));
            });

            Assert.IsTrue(operation.Succeeded);
            Assert.AreEqual(3, operation.Result);
        }
Example #37
0
        public void AsyncOperationCreationSuccess()
        {
            var task = Operation.Run(async() =>
            {
                await Task.Run(() => Console.WriteLine("Hello Operation"));
            });

            task.Wait();

            Assert.IsTrue(task.Result.Succeeded);
        }
Example #38
0
        public void AsyncOperationCreationFailure()
        {
            var task = Operation.Run(async() =>
            {
                await Task.Run(() => Console.WriteLine("Hello Operation"));
                throw new Exception("The Error");
            });

            task.Wait();

            Assert.IsFalse(task.Result.Succeeded);
            Assert.AreEqual(task.Result.Message, "The Error");
        }
Example #39
0
        public void CreateBindCatchesExceptions()
        {
            var operation = Operation.CreateBind(() =>
            {
                var x = true;
                if (x)
                {
                    throw new Exception("Some Error");
                }
                return(Operation.Success(2));
            });

            Assert.IsFalse(operation.Succeeded);
            Assert.AreEqual("Some Error", operation.Message);
        }
Example #40
0
        public void OperationResultFailure()
        {
            var cond      = true;
            var operation = Operation.Create(() =>
            {
                if (cond)
                {
                    throw new Exception("The Error");
                }
                return(1);
            });

            Assert.IsFalse(operation.Succeeded);
            Assert.AreEqual(operation.Message, "The Error");
            Assert.AreEqual(operation.Result, default(int));
        }
Example #41
0
        public void CreateSuccess()
        {
            var operation = Operation.Create(_methods.Void);

            Assert.IsTrue(operation.Succeeded);
        }
Example #42
0
        public void OperationCreationSuccess()
        {
            var operation = Operation.Create(_methods.Print);

            Assert.IsTrue(operation.Succeeded);
        }