private void HandleIncrementMessage(IncrementPlayCountMessage mes)
        {
            if (_moviePlayCounts.ContainsKey(mes.MovieTitle))
            {
                _moviePlayCounts[mes.MovieTitle]++;
            }
            else
            {
                _moviePlayCounts.Add(mes.MovieTitle, 1);
            }

            // simulated bugs
            if (_moviePlayCounts[mes.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException();
            }

            if (mes.MovieTitle == "Terrible movie")
            {
                throw new SimulatedTerribleMovieException();
            }

            ColorConsole.WriteColorLine(
                $"MoviePlayCounterActor '{mes.MovieTitle}' has been watched {_moviePlayCounts[mes.MovieTitle]}",
                ConsoleColor.Magenta);
        }
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts[message.MovieTitle]++;
            }
            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }

            //  Simulated bugs
            if (_moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException();
            }

            if (message.MovieTitle == "Partial Recoil")
            {
                throw new SimulatedTerribleMovieException();
            }

            ColorConsole.WriteMagenta(
                $"MoviePlayCounterActor '{message.MovieTitle}' has been watched {_moviePlayCounts[message.MovieTitle]} times");
        }
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (moviePlayCounts.ContainsKey(message.Title))
            {
                moviePlayCounts[message.Title]++;
            }
            else
            {
                moviePlayCounts.Add(message.Title, 1);
            }

            //simulated bug
            if (moviePlayCounts[message.Title] > 3)
            {
                throw new SimulatedCorruptStateException();
            }

            //simulated bug
            if (message.Title == "Terminator")
            {
                throw new SimulatedBadMovieException();
            }

            if (message.Title == "Terminator2")
            {
                throw new SimulatedExtraBadMovieException();
            }


            var numberOfPlays = moviePlayCounts[message.Title];

            Console.WriteLine("Movie Play Counter: " +
                              "The movie {0} has been played {1} times.",
                              message.Title, numberOfPlays);
        }
Beispiel #4
0
        private void HandleIncrementPlayCountMesage(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts[message.MovieTitle]++;
            }

            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }


            // simulated bugs
            // if we get a title played more than 3 times we throw this simulatedCorruptStateException error
            if (_moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException();
            }

            if (message.MovieTitle == "Partial Recoil")
            {
                throw new TerribleMovieException();
            }

            Console.WriteLine($"MoviePlayCounterActor '{message.MovieTitle}' has been watched {_moviePlayCounts[message.MovieTitle]}");
        }
Beispiel #5
0
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                moviePlayCounts[message.MovieTitle]++;
            }
            else
            {
                moviePlayCounts[message.MovieTitle] = 1;
            }

            //Simulate some bugs
            if (moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException();
            }

            if (message.MovieTitle.Contains("bad"))
            {
                throw new SimulatedTerribleMovieException();
            }


            ColorConsole.WriteLineMagenta("MoviePlayCounterActor '{0}' has been watched {1} times", message.MovieTitle, moviePlayCounts[message.MovieTitle]);
        }
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                var currentCount = _moviePlayCounts[message.MovieTitle];

                currentCount++;

                _moviePlayCounts[message.MovieTitle] = currentCount;
            }
            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }

            //  Simulated bugs
            if (message.MovieTitle == "Partial Recoil")
            {
                throw new SimulatedTerribleMovieException(message.MovieTitle);
            }

            if (message.MovieTitle == "Partial Recoil 2")
            {
                throw new InvalidOperationException("Simulated exception");
            }

            _logger.Info("MoviePlayCounterActor {Movie} has been watched {Times} times", message.MovieTitle, _moviePlayCounts[message.MovieTitle]);
        }
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            var key = message.MovieTitle;

            if (this.moviePlayCounts.ContainsKey(key))
            {
                this.moviePlayCounts[key]++;
            }
            else
            {
                this.moviePlayCounts.Add(key, 1);
            }

            // SIMULATED BUGS
            if (moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException(); // strategy is to RESTART this child
            }

            if (message.MovieTitle == "Partial Recoil")
            {
                throw new SimulatedTerribleMovieException(); // strategy is to RESUME this child, although...
                // it will resume only on the next message, which means that the following Console.Write will not be executed
                // but its counter will remain the same because this actor is not restarted
            }

            ColorConsole.WriteLineMagenta(
                string.Format("MoviePlayCounterActor '{0}' has been watched {1} times", key, moviePlayCounts[key]));
        }
        private void ProcessIncrementPlayCountMessage(IncrementPlayCountMessage message)
        {
            if (!_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts.Add(message.MovieTitle, 0);
            }
            _moviePlayCounts[message.MovieTitle]++;

            ColorConsole.WriteMagenta($"MoviePlayerCounterActor '{message.MovieTitle}' has been watched {_moviePlayCounts[message.MovieTitle]} times");
        }
        private void SimulateBugs(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCurruptStateException();
            }

            if (string.Equals(message.MovieTitle, "InDaHouse", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new SimulatedTerribleMovieException();
            }
        }
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts[message.MovieTitle]++;
            }
            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }

            ColorConsole.WriteMagenta(
                "MoviePlayCounterActor '{0}' has been watched {1} times",
                message.MovieTitle, _moviePlayCounts[message.MovieTitle]);
        }
Beispiel #11
0
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            var recentlyPlayedMoviesBufferIsFull = _recentlyPlayedMovies.Count == NumberOfRecentMoviesToAnalyze;

            if (recentlyPlayedMoviesBufferIsFull)
            {
                // remove oldest movie title
                _recentlyPlayedMovies.Dequeue();
            }

            _recentlyPlayedMovies.Enqueue(message.MovieTitle);

            LogDebug();

            var topMovie = _trendAnalyzer.CalculateMostPopularMovie(_recentlyPlayedMovies);

            _logger.Info("TrendingMoviesActor most popular movie trending now is {0}", topMovie);
        }
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (!_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts.Add(message.MovieTitle, 0);
            }
            _moviePlayCounts[message.MovieTitle]++;
            if (_moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException();
            }
            if (message.MovieTitle == "Partial Recoil")
            {
                throw new SimulatedTerribleMovieException();
            }

            ColorConsole.WriteLine($"MoviePlayCountActor '{message.MovieTitle}' has been watched {_moviePlayCounts[message.MovieTitle]} times", ConsoleColor.Magenta);
        }
Beispiel #13
0
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts[message.MovieTitle]++;
            }
            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }

            if (_moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException();
            }

            if (message.MovieTitle == "aha")
            {
                throw new SimulatedTerribleMovieException();
            }

            ColorConsole.WriteMagenta("MoviePlayCounterActor '{0}' has been watchend {1} times", message.MovieTitle, _moviePlayCounts[message.MovieTitle]);
        }
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (message.MovieTitle == "corrupt")
            {
                throw new SimulatedInvalidMovieException();
            }

            if (message.MovieTitle == "boom")
            {
                throw new SimulatedCorruptStateException();
            }

            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts[message.MovieTitle]++;
            }
            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }

            ColorConsole.WriteLine($"MoviePlayCounterActor '{message.MovieTitle}' has been watched {_moviePlayCounts[message.MovieTitle]} times.", ConsoleColor.Magenta);
        }
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts[message.MovieTitle]++;
            }
            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }

            //  Simulated bugs
            if (message.MovieTitle == "Partial Recoil")
            {
                throw new SimulatedTerribleMovieException(message.MovieTitle);
            }

            if (message.MovieTitle == "Partial Recoil 2")
            {
                throw new InvalidOperationException("Simulated exception");
            }

            // TODO: log: MoviePlayCounterActor message.MovieTitle has been watched _moviePlayCounts[message.MovieTitle] times
        }
Beispiel #16
0
        private void HandleIncrementMessage(IncrementPlayCountMessage message)
        {
            if (_moviePlayCounts.ContainsKey(message.MovieTitle))
            {
                _moviePlayCounts[message.MovieTitle]++;
            }
            else
            {
                _moviePlayCounts.Add(message.MovieTitle, 1);
            }

            // simulate bugs...
            if (_moviePlayCounts[message.MovieTitle] > 3)
            {
                throw new SimulatedCorruptStateException();
            }

            if (message.MovieTitle.Equals("partial recoil", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new SimulatedTerribleMovieException();
            }

            _logger.WriteDebug($"{Self.Path.Name}: {message.MovieTitle} has been watched {_moviePlayCounts[message.MovieTitle]} time(s)");
        }