Exemplo n.º 1
0
        public void SaveBlindSpotNotificationTest()
        {
            //arrange
            var request = new BlindSpotNotification
            {
                coworkerid = new List <string>
                {
                    "1", "2", "3"
                },
                userid = ""
            };
            var response = new List <Feedback>
            {
                new Feedback {
                }
            };
            var settings = new MongoDbSettings {
                FeedbackCollection = "", FeedbackReplyCollection = ""
            };

            _settings.Setup(s => s.Value).Returns(settings);
            _mokgetFeedbackDetailsAdapter.Setup(a => a.GetLastAddedFeedback()).Returns(1);
            _mokstoreFeedbackAdapter.Setup(a => a.SaveFeedbackQuestion(It.IsAny <Feedback>()));
            //act
            var feedbackAdapter = new FeedbackBusinessLogics(_mokstoreFeedbackAdapter.Object, _mokgetFeedbackDetailsAdapter.Object);

            feedbackAdapter.SaveBlindSpotNotification(request);

            //assert
            _mokgetFeedbackDetailsAdapter.Verify(a => a.GetLastAddedFeedback());
            _mokstoreFeedbackAdapter.Verify(a => a.SaveFeedbackQuestion(It.IsAny <Feedback>()));
        }
        public void SaveBlindSpotUserResponse(BlindSpotQuizAttempts response)
        {
            response.id           = _blindSpotAdapter.GetLastInsertedAttemptId() + 1;
            response.attemptcount = _blindSpotAdapter.GetLatestAttemptByUser(response.userid)?.attemptcount + 1 ?? 1;
            _blindSpotAdapter.SaveBlindSpotUserResponse(response);

            var lastRecordCount = _blindSpotAdapter.GetLastInsertedCoWorkerReply();

            foreach (var coWorker in response.selectedcoWorkers)
            {
                if (coWorker != null)
                {
                    lastRecordCount++;
                    BlindSpotCoWorkerReply coWorkerReply = new BlindSpotCoWorkerReply
                    {
                        id                 = lastRecordCount,
                        attemptid          = response.id,
                        userid             = coWorker,
                        replytimestamp     = DateTime.Now.ToString(CultureInfo.InvariantCulture),
                        selectedadjectives = new string[] { }
                    };

                    _blindSpotAdapter.SaveBlindSpotCoWorkerResponse(coWorkerReply);
                }
            }

            BlindSpotNotification notification = new BlindSpotNotification()
            {
                userid = response.userid, coworkerid = response.selectedcoWorkers.Where(x => x != null)?.ToList()
            };

            _feedbackAdapter.SendNotification(notification);
        }
        public void SendNotification(BlindSpotNotification notification)
        {
            ServiceRequest request = new ServiceRequest
            {
                Url                 = _config.Value.FeedbackServiceUrl + "saveBlindSpotNotification",
                ContentType         = "application/json",
                HttpMethod          = "POST",
                Request             = JsonConvert.SerializeObject(notification),
                AuthorizationHeader = _httpContextAccessor.HttpContext.GetTokenAsync("access_token")?.Result
            };
            var webRequest = _serviceHelper.CreateWebRequest(request);
            BaseHttpResponse webResponse = _serviceHelper.HandleRequest(webRequest);

            if (webResponse.HttpStatusCode != HttpStatusCode.OK)
            {
                _log.LogError(webResponse.Description);
            }
        }
        public void SendNotificationTest()
        {
            //Arrange
            var nofification     = new BlindSpotNotification();
            var baseHttpResponse = new BaseHttpResponse
            {
                HttpStatusCode = HttpStatusCode.OK
            };
            Mock <HttpRequest> request = new Mock <HttpRequest>();

            request.Setup(x => x.Headers).Returns(new HeaderDictionary());
            _mockHttpContext.Setup(x => x.Request).Returns(request.Object);

            Mock <IAuthenticationService> auth    = new Mock <IAuthenticationService>();
            Mock <IServiceProvider>       service = new Mock <IServiceProvider>();

            service.Setup(x => x.GetService(It.IsAny <Type>())
                          ).Returns(auth.Object
                                    );

            _mockHttpContext.Setup(x => x.RequestServices).Returns(
                service.Object);

            _mokhttpContextAccessor.Setup(_ => _.HttpContext).Returns(
                _mockHttpContext.Object
                );
            var settings = new ServiceSettings {
                FeedbackServiceUrl = "http://localhost:8080/Feedback/"
            };
            var serviceResponse = (HttpWebRequest)WebRequest.Create(new Uri(settings.FeedbackServiceUrl + "saveBlindSpotNotification"));

            _mokconfig.Setup(s => s.Value).Returns(settings);
            _mokserviceHelper.Setup(s => s.CreateWebRequest(It.IsAny <ServiceRequest>())).Returns(serviceResponse);
            _mokserviceHelper.Setup(s => s.HandleRequest(serviceResponse)).Returns(baseHttpResponse);

            //Act
            _feedbackAdapter = new FeedbackAdapter(_mokserviceHelper.Object, _mokconfig.Object, _moklog.Object, _mokhttpContextAccessor.Object);
            _feedbackAdapter.SendNotification(nofification);

            //Assert
            _mokserviceHelper.Verify(s => s.CreateWebRequest(It.IsAny <ServiceRequest>()));
            _mokserviceHelper.Verify(s => s.HandleRequest(serviceResponse));
        }
Exemplo n.º 5
0
        public void SaveBlindSpotNotification(BlindSpotNotification blindSpotNotification)
        {
            foreach (var coworker in blindSpotNotification.coworkerid)
            {
                Feedback feedback = new Feedback
                {
                    id              = _getFeedbackDetailsAdapter.GetLastAddedFeedback() + 1,
                    assigned        = coworker,
                    createtimestamp = DateTime.Now.ToString(),
                    question        = "You have been requested for blind spot by your friend " + blindSpotNotification.userid,
                    status          = "pending",
                    updatetimestamp = DateTime.Now.ToString(),
                    type            = "blindspot",
                    userid          = blindSpotNotification.userid
                };

                _storeFeedbackAdapter.SaveFeedbackQuestion(feedback);
            }
        }
Exemplo n.º 6
0
        public void GetNotificationCountTest()
        {
            //arrange
            var request = new BlindSpotNotification
            {
                coworkerid = new List <string>
                {
                    "1", "2", "3"
                },
                userid = ""
            };
            var response = new List <Feedback>
            {
                new Feedback {
                    id = 1
                }
            };
            var feedbackreplyresponse = new FeedbackReply
            {
                feedback = "feedback"
            };
            var settings = new MongoDbSettings {
                FeedbackCollection = "", FeedbackReplyCollection = ""
            };

            _settings.Setup(s => s.Value).Returns(settings);
            _mokgetFeedbackDetailsAdapter.Setup(a => a.GetFeedBacksAssignedToUser(It.IsAny <string>())).Returns(response);
            _mokgetFeedbackDetailsAdapter.Setup(a => a.GetFeedbackRequestsByUser(It.IsAny <string>())).Returns(response);
            _mokgetFeedbackDetailsAdapter.Setup(a => a.GetFeedbackReplyForQuestion(It.IsAny <long>())).Returns(feedbackreplyresponse);
            //act
            var feedbackAdapter = new FeedbackBusinessLogics(_mokstoreFeedbackAdapter.Object, _mokgetFeedbackDetailsAdapter.Object);
            var result          = feedbackAdapter.GetNotificationCount("1");

            //assert
            _mokgetFeedbackDetailsAdapter.Verify(a => a.GetFeedBacksAssignedToUser(It.IsAny <string>()));
            _mokgetFeedbackDetailsAdapter.Verify(a => a.GetFeedbackRequestsByUser(It.IsAny <string>()));
            _mokgetFeedbackDetailsAdapter.Verify(a => a.GetFeedbackReplyForQuestion(It.IsAny <long>()));
            Assert.IsInstanceOf <long>(result);
        }
 public void SaveBlindSpotNotification(BlindSpotNotification blindSpotNotification)
 {
     _feedbackBusinessLogics.SaveBlindSpotNotification(blindSpotNotification);
 }
Exemplo n.º 8
0
 public void SaveBlindSpotNotification(BlindSpotNotification blindSpotNotification)
 {
     _dashboardBusinessLogics.SaveBlindSpotNotification(blindSpotNotification);
 }
Exemplo n.º 9
0
 public void SaveBlindSpotNotification(BlindSpotNotification blindSpotNotification)
 {
     _feedbackAdapter.SaveBlindSpotNotification(blindSpotNotification);
 }