Пример #1
0
        public void GetUserLogs_ShouldGetFullListOfUserLogs()
        {
            _userLogsRepository.GetUserLogs().Returns(new List <UserLog>
            {
                new UserLog
                {
                    Id         = 1,
                    SearchTime = 100,
                    Phrase     = new Phrase {
                        Id = 1, Text = "Angela Merkel"
                    },
                    Anagram = new Anagram {
                        Id = 1, Text = "Karamelengel"
                    },
                    User = new User {
                        Id = 1, Ip = "::1", SearchesLeft = 5
                    }
                },
                new UserLog
                {
                    Id         = 2,
                    SearchTime = 100,
                    Phrase     = new Phrase {
                        Id = 1, Text = "Angela Merkel"
                    },
                    Anagram = new Anagram {
                        Id = 1, Text = "klare Maengel"
                    },
                    User = new User {
                        Id = 1, Ip = "::1", SearchesLeft = 5
                    }
                },
                new UserLog
                {
                    Id         = 3,
                    SearchTime = 100,
                    Phrase     = new Phrase {
                        Id = 1, Text = "Angela Merkel"
                    },
                    Anagram = new Anagram {
                        Id = 1, Text = "gare kamellen"
                    },
                    User = new User {
                        Id = 1, Ip = "::1", SearchesLeft = 5
                    }
                }
            });

            var userLogsResult = _userLogsService.GetUserLogs();

            _userLogsRepository.Received().GetUserLogs();
            userLogsResult.ShouldNotBeNull();
            userLogsResult.ShouldNotBeEmpty();
            userLogsResult.First().ShouldBeOfType(typeof(UserLog));
            userLogsResult.First().Anagram.Text.ShouldBe("Karamelengel");
        }
Пример #2
0
        public void GetSearchHistory_ShouldGetAllUserSearchHistory()
        {
            var ip   = "10.11.19.188";
            var list = new List <SearchHistoryDto>
            {
                new SearchHistoryDto {
                    UserIp       = "10.11.19.188",
                    SearchTime   = 5,
                    SearchedWord = "alus",
                    Anagrams     = new List <string>
                    {
                        "alus", "sula"
                    }
                },
                new SearchHistoryDto {
                    UserIp       = "10.11.19.188",
                    SearchTime   = 10,
                    SearchedWord = "alus",
                    Anagrams     = new List <string>
                    {
                        "alus", "sula"
                    }
                },
                new SearchHistoryDto {
                    UserIp       = "10.11.19.188",
                    SearchTime   = 15,
                    SearchedWord = "alus",
                    Anagrams     = new List <string>
                    {
                        "alus", "sula"
                    }
                },
                new SearchHistoryDto {
                    UserIp       = "10.11.19.188",
                    SearchTime   = 11,
                    SearchedWord = "abipus",
                    Anagrams     = new List <string>
                    {
                        "api", "bus"
                    }
                },
            };

            _userLogRepository.GetSearchHistory(ip).Returns(list);

            var result = _userLogService.GetSearchHistory(ip);

            result.ShouldNotBeNull();
            result.First().ShouldBe(list[0]);

            _userLogRepository.Received().GetSearchHistory(ip);
        }