Exemplo n.º 1
0
        private static void DeleteComment(CafeController cafeController)
        {
            if (cafeController is null)
            {
                throw new ArgumentNullException(nameof(cafeController));
            }

            Console.WriteLine(resourceManager.GetString("ChooseCafe", culture));
            ShowCafes(cafeController);

            while (true)
            {
                var choice = Console.ReadLine();
                var cafe   = cafeController.GetCafe(choice);
                if (cafe != null)
                {
                    var isDelete = cafeController.DeleteComment(cafe);
                    if (isDelete)
                    {
                        Console.WriteLine(resourceManager.GetString("DeleteSuccessfully"));
                    }
                    else
                    {
                        ShowError(resourceManager.GetString("NoComment"));
                    }
                    break;
                }
                else
                {
                    ShowError(resourceManager.GetString("ErrorDoesNotExistCafe", culture));
                }
            }
        }
Exemplo n.º 2
0
        private static void ShowCommentsCafe(CafeController cafeController)
        {
            #region Проверка
            if (cafeController is null)
            {
                throw new ArgumentNullException(nameof(cafeController));
            }
            #endregion

            ShowCafes(cafeController);
            string cafeName;
            while (true)
            {
                cafeName = Console.ReadLine();
                if (cafeController.GetCafe(cafeName) != null)
                {
                    break;
                }
                else
                {
                    ShowError(resourceManager.GetString("ErrorInvalidInput", culture));
                    return;
                }
            }

            var commentsCafe = cafeController.GetComments().Where(c => c.CafeName == cafeName);
            foreach (var comment in commentsCafe)
            {
                Console.WriteLine(comment);
            }
        }
Exemplo n.º 3
0
        private static void AddComment(CafeController cafeController)
        {
            if (cafeController is null)
            {
                throw new ArgumentNullException(nameof(cafeController));
            }

            Console.WriteLine(resourceManager.GetString("ChooseCafe", culture));
            ShowCafes(cafeController);

            while (true)
            {
                var choice = Console.ReadLine();
                var cafe   = cafeController.Cafes.FirstOrDefault(c => c.Name == choice);
                if (cafe != null)
                {
                    Console.Write(resourceManager.GetString("EnterRating", culture));
                    var rating = EnterRating();

                    Console.Write(resourceManager.GetString("EnterComment", culture));
                    var comment = Console.ReadLine();

                    var userComment = new UserComment(cafeController.CurrentUser, cafe.Name, rating, comment);
                    cafeController.AddComment(userComment);
                    break;
                }
                else
                {
                    ShowError(resourceManager.GetString("ErrorDoesNotExistCafe", culture));
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColorText;
            Console.WriteLine(resourceManager.GetString("Hello", culture));

            Console.Write(resourceManager.GetString("EnterName", culture));
            var name = Console.ReadLine();

            var userController = new UserController(name);

            if (userController.IsNewUser)
            {
                Console.Write(resourceManager.GetString("EnterGender", culture));
                var gender    = Console.ReadLine();
                var birthDate = ParseDate();

                userController.SetNewUserDate(gender, birthDate);
            }

            var cafeController = new CafeController(userController.CurrentUser);

            ShowCommands();
            while (true)
            {
                Console.Write(">> ");
                var choice = Console.ReadLine();

                switch (choice)
                {
                case "help":
                    ShowCommands();
                    break;

                case "comment":
                    AddComment(cafeController);
                    break;

                case "delete":
                    DeleteComment(cafeController);
                    break;

                case "cafes":
                    ShowCafes(cafeController);
                    break;

                case "comments":
                    ShowCommentsCafe(cafeController);
                    break;

                case "exit":
                    Environment.Exit(0);
                    break;

                default:
                    ShowError(resourceManager.GetString("UnknownCommand", culture));
                    break;
                }
            }
        }
Exemplo n.º 5
0
        private static void ShowCafes(CafeController cafeController)
        {
            if (cafeController is null)
            {
                throw new ArgumentNullException(nameof(cafeController));
            }

            foreach (var cafe in cafeController.Cafes)
            {
                Console.WriteLine("{0, 12} \t Средняя оценка: {1, 3} ({2} комментариев)", cafe.Name, cafeController.GetRating(cafe), cafeController.GetComments().Where(c => c.CafeName == cafe.Name).Count());
            }
        }
Exemplo n.º 6
0
        public void Check_PostPCoffee()
        {
            //arrange
            var item = GetDemoCoffee();

            Mock <ICoffeeRepository> mockRepository = new Mock <ICoffeeRepository>();

            mockRepository.Setup(x => x.Add(item)).Verifiable();

            CafeController controller = controller = new CafeController(mockRepository.Object);
            var            result     = controller.PostCoffee(item);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult <bool>));
        }
Exemplo n.º 7
0
        public void AddCommentTest()
        {
            // Arrange
            var userName       = "******";
            var rnd            = new Random();
            var user           = new User(userName);
            var cafe           = new Cafe("KFT");
            var userComment    = new UserComment(user, cafe.Name, rnd.Next(1, 6), Guid.NewGuid().ToString());
            var cafeController = new CafeController(user);

            // Act
            cafeController.AddComment(userComment);

            // Assert
            Assert.IsTrue(cafeController.GetComments().SingleOrDefault(c => c.Comment == userComment.Comment) != null);
        }
Exemplo n.º 8
0
        public void Check_GetLastCoffee()
        {
            var item = GetDemoCoffee();

            Mock <ICoffeeRepository> mockRepository = new Mock <ICoffeeRepository>();

            mockRepository.Setup(x => x.GetLast()).Returns(item);

            CafeController controller = controller = new CafeController(mockRepository.Object);

            controller = new CafeController(mockRepository.Object);

            var result = controller.GetLastCoffee() as OkNegotiatedContentResult <CoffeeModel>;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult <CoffeeModel>));
        }
Exemplo n.º 9
0
        public void DeleteCommentTest()
        {
            // Arrange
            var userName       = "******";
            var rnd            = new Random();
            var user           = new User(userName);
            var cafeController = new CafeController(user);

            // Act
            var cafe        = cafeController.GetCafe("BlackWhite");
            var userComment = new UserComment(user, cafe.Name, rnd.Next(1, 6), Guid.NewGuid().ToString());

            cafeController.AddComment(userComment);
            cafeController.DeleteComment(cafe);

            // Assert
            Assert.IsTrue(cafeController.GetComments().Where(c => c.CafeName == cafe.Name).Count() == 0);
        }
Exemplo n.º 10
0
        public void Check_GetTypeCoffee()
        {
            var item = GetAllType();

            Mock <ICoffeeRepository> mockRepository = new Mock <ICoffeeRepository>();

            mockRepository.Setup(x => x.GetAllType()).Returns(item);

            CafeController controller = controller = new CafeController(mockRepository.Object);

            controller = new CafeController(mockRepository.Object);

            var result = controller.GetTypeCoffee();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IList <TypeCoffeeModel>));
            Assert.AreEqual(2, result.Count);
        }
Exemplo n.º 11
0
 private void LoadGrid()
 {
     cafe_dataGrid.DataSource = CafeController.GetPositions(service, dbId);
 }
 void Start()
 {
     cafe  = GameObject.FindGameObjectWithTag("Cafe").GetComponent <CafeController>();
     image = gameObject.GetComponent <Image>();
 }