Esempio n. 1
0
        public async Task ApiSequenceTests()
        {
            this.ControllersContext = await ControllersContext.ConstructControllersContext();

            var seq1 = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostUser201, null, this.DeleteUser204
            };
            var seq2 = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostUser201, this.PostUser409, this.DeleteUser204
            };
            var seq3 = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostUser201, this.DeleteUser204, this.DeleteUser404
            };
            var seq4 = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostUser201, this.PutUser204, this.DeleteUser204
            };
            var seq5 = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostUser201, this.GetUser200, this.DeleteUser204
            };

            await ApiSequenceTestingFramework.Execute(seq1);

            await ApiSequenceTestingFramework.Execute(seq2);

            await ApiSequenceTestingFramework.Execute(seq3);

            await ApiSequenceTestingFramework.Execute(seq4);

            await ApiSequenceTestingFramework.Execute(seq5);
        }
        public async Task ApiSequenceTest()
        {
            this.ControllersContext = await ControllersContext.ConstructControllersContext();

            this.ControllersContextWithNullUserHandle = await ControllersContext.ConstructControllersContextWithNullUserHandle();

            //// Sequence #1: PostUser, PostLinkedAccount, PostLinkedAccount, DeleteUser

            var result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            PostUserResponse postUserResponse = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;

            this.SessionToken = postUserResponse.SessionToken;

            var seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostLinkedAccount204, this.PostLinkedAccount409, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #2: PostUser, PostLinkedAccount, DeleteLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostLinkedAccount204, this.DeleteLinkedAccount204, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #3: PostUser, PostLinkedAccount, GetLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostLinkedAccount204, this.GetLinkedAccounts200, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #4: PostUser, PostLinkedAccount, DeleteUser, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostLinkedAccount204, this.DeleteUser204, this.DeleteUser404
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #5: PostUser, DeleteLinkedAccount, PostLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.DeleteLinkedAccount404, this.PostLinkedAccount204, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #6: PostUser, DeleteLinkedAccount, DeleteLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.DeleteLinkedAccount404, this.DeleteLinkedAccount404, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #7: PostUser, DeleteLinkedAccount, GetLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.DeleteLinkedAccount404, this.GetLinkedAccounts200, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #8: PostUser, DeleteLinkedAccount, DeleteUser, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.DeleteLinkedAccount404, this.DeleteUser204, this.DeleteUser404
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #9: PostUser, GetLinkedAccount, PostLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.GetLinkedAccounts200, this.PostLinkedAccount204, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #10: PostUser, GetLinkedAccount, DeleteLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.GetLinkedAccounts200, this.DeleteLinkedAccount404, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #11: PostUser, GetLinkedAccount, GetLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.GetLinkedAccounts200, this.GetLinkedAccounts200, this.DeleteUser204
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #12: PostUser, GetLinkedAccount, DeleteUser, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.GetLinkedAccounts200, this.DeleteUser204, this.DeleteUser404
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #13: PostUser, DeleteUser, PostLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.DeleteUser204, this.PostLinkedAccount204, this.DeleteUser404
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #14: PostUser, DeleteUser, DeleteLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.DeleteUser204, this.DeleteLinkedAccount404, this.DeleteUser404
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #15: PostUser, DeleteUser, GetLinkedAccount, DeleteUser

            result = await ApiSequenceTestingFramework.Execute(this.PostUser201);

            postUserResponse  = (result as CreatedNegotiatedContentResult <PostUserResponse>).Content;
            this.SessionToken = postUserResponse.SessionToken;

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.DeleteUser204, this.GetLinkedAccounts200, this.DeleteUser404
            };
            await ApiSequenceTestingFramework.Execute(seq);

            //// Sequence #16: PostUser, DeleteUser, DeleteUser, DeleteUser

            seq = new List <Tuple <Func <Task <IHttpActionResult> >, Action <IHttpActionResult> > > {
                this.PostUser201, this.DeleteUser204, this.DeleteUser404, this.DeleteUser404
            };
            await ApiSequenceTestingFramework.Execute(seq);
        }