/// <summary>
        /// add...
        /// </summary>
        /// <param name="theCandidate">the candidate (touchpoint)</param>
        /// <returns>the newly stored routing details (touchpoint)</returns>
        public async Task <IRoutingDetail> Add(IncomingRoutingDetail theCandidate)
        {
            It.IsNull(theCandidate)
            .AsGuard <ArgumentNullException>(nameof(theCandidate));

            var theTouchpoint = theCandidate?.TouchpointID;

            It.IsEmpty(theTouchpoint)
            .AsGuard <ArgumentNullException>(nameof(theTouchpoint));

            var usingPath = StoragePaths.GetRoutingDetailResourcePathFor(theTouchpoint);

            (await DocumentStore.DocumentExists <RoutingDetail>(usingPath, _partitionKey))
            .AsGuard <ConflictingResourceException>();

            return(await DocumentStore.AddDocument(theCandidate, StoragePaths.RoutingDetailCollection));
        }
Exemplo n.º 2
0
        public async Task CreateDocumentAsyncMeetsExpectation()
        {
            // arrange
            const string keyValue = "0000123";
            var          sut      = MakeSUT();
            var          document = new IncomingRoutingDetail {
                TouchpointID = keyValue
            };
            var collectionUri = new Uri("dbs/areas/colls/routing", UriKind.Relative);
            var documentUri   = new Uri($"dbs/areas/colls/routing/docs/{keyValue}", UriKind.Relative);

            GetMock(sut.Client)
            .Setup(x => x.CreateDocumentAsync(collectionUri, document, null, false, default))
            .Returns(Task.FromResult(new ResourceResponse <Document>(new Document())));
            GetMock(sut.Client)
            .Setup(x => x.ReadDocumentAsync <IncomingRoutingDetail>(documentUri, It.IsAny <RequestOptions>(), default))
            .Returns(Task.FromResult(new DocumentResponse <IncomingRoutingDetail>(document)));

            // act
            var result = await sut.CreateDocumentAsync(collectionUri, document);

            // assert
            Assert.IsAssignableFrom <IRoutingDetail>(result);
        }