private readonly Mock <ILogger <ConsultantsController> > logger;    //create Moq object of Serilog

        public ConsultantsControllerUnitTests()
        {
            mockService = new Mock <IService>();

            logger = new Mock <ILogger <ConsultantsController> >();

            //Setup moq controller with moq objects and local version of automapper
            consultantsController        = new ConsultantsController(mockService.Object, logger.Object);
            expectedListShopsConsultants = GetExpectedListShopsConsultants();

            //Setup all methods of the moq object of Repository
            mockService.Setup(m => m.GetShopsConsultants()).Returns(Task.FromResult(expectedListShopsConsultants));

            mockService.Setup(m => m.AddConsultant(It.IsAny <AddConsultantViewModel>()))
            .Returns((AddConsultantViewModel target) =>
            {
                expectedListShopsConsultants.Consultants.Add(4, target.Name);
                return(Task.FromResult(true));
            });

            mockService.Setup(m => m.AppointConsultant(It.IsAny <AppointConsultantViewModel>()))
            .Returns((AppointConsultantViewModel target) =>
            {
                string shopName;
                var shop = expectedListShopsConsultants.Shops.
                           TryGetValue(Convert.ToInt32(target.ShopId), out shopName);
                if (shop)
                {
                    return(Task.FromResult(true));
                }

                return(Task.FromResult(false));
            });
        }
        public void Get_WhenCalled_ReturnsListShopsConsultants()
        {
            // Act
            var okResult = consultantsController.GetShopsConsultants().Result as OkObjectResult;

            ListShopsConsultants models = expectedListShopsConsultants;

            // Assert
            var list = Assert.IsType <ListShopsConsultants>(okResult.Value);

            Assert.Equal(models, (okResult.Value as ListShopsConsultants));
        }
        private static ListShopsConsultants GetExpectedListShopsConsultants()
        {
            Dictionary <int, string> shops       = new Dictionary <int, string>();
            Dictionary <int, string> consultants = new Dictionary <int, string>();

            shops.Add(1, "Магазин 1");
            shops.Add(2, "Магазин 2");
            shops.Add(3, "Магазин 3");
            consultants.Add(1, "Консультант 1");
            consultants.Add(2, "Консультант 2");
            consultants.Add(3, "Консультант 3");
            ListShopsConsultants list = new ListShopsConsultants()
            {
                Shops       = shops,
                Consultants = consultants
            };

            return(list);
        }