public SegmentServicePatchTests() : base()
        {
            testGuid = Guid.NewGuid();
            currentOpportunitiesSegmentPatchStatus = new CurrentOpportunitiesSegmentPatchStatus()
            {
                OkToPatch        = true,
                ReturnStatusCode = HttpStatusCode.OK,
            };
            A.CallTo(() => FakeCurrentOpportunitiesSegmentUtilities.IsSegementOkToPatch(A <CurrentOpportunitiesSegmentModel> .Ignored, A <long> .Ignored)).Returns(currentOpportunitiesSegmentPatchStatus);

            currentOpportunitiesSegmentModel = new CurrentOpportunitiesSegmentModel()
            {
                Data = new CurrentOpportunitiesSegmentDataModel()
                {
                },
            };
            A.CallTo(() => FakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(currentOpportunitiesSegmentModel);
        }
Exemple #2
0
        public CurrentOpportunitiesSegmentPatchStatus IsSegementOkToPatch(CurrentOpportunitiesSegmentModel currentOpportunitiesSegmentModel, long patchSequenceNumber)
        {
            var currentOpportunitiesSegmentPatchStatus = new CurrentOpportunitiesSegmentPatchStatus()
            {
                OkToPatch = true, ReturnStatusCode = HttpStatusCode.OK
            };

            if (currentOpportunitiesSegmentModel is null)
            {
                currentOpportunitiesSegmentPatchStatus.ReturnStatusCode = HttpStatusCode.NotFound;
                currentOpportunitiesSegmentPatchStatus.OkToPatch        = false;
            }
            else if (patchSequenceNumber <= currentOpportunitiesSegmentModel.SequenceNumber)
            {
                currentOpportunitiesSegmentPatchStatus.ReturnStatusCode = HttpStatusCode.AlreadyReported;
                currentOpportunitiesSegmentPatchStatus.OkToPatch        = false;
            }

            return(currentOpportunitiesSegmentPatchStatus);
        }
        public async Task JobProfileSocPatchSocReturnsNotFoundForMissingSegment()
        {
            //Arrange
            var doNotPatchResult = new CurrentOpportunitiesSegmentPatchStatus()
            {
                OkToPatch = false, ReturnStatusCode = HttpStatusCode.NotFound
            };
            var patchJobProfileSocModel = new PatchJobProfileSocModel()
            {
                ActionType = MessageAction.Deleted
            };

            A.CallTo(() => FakeRepository.GetAsync(A <Expression <Func <CurrentOpportunitiesSegmentModel, bool> > > .Ignored)).Returns(null as CurrentOpportunitiesSegmentModel);
            A.CallTo(() => FakeCurrentOpportunitiesSegmentUtilities.IsSegementOkToPatch(A <CurrentOpportunitiesSegmentModel> .Ignored, A <long> .Ignored)).Returns(doNotPatchResult);

            //Act
            var result = await CurrentOpportunitiesSegmentService.PatchJobProfileSocAsync(patchJobProfileSocModel, testGuid).ConfigureAwait(false);

            //Asserts
            result.Should().Be(HttpStatusCode.NotFound);
        }