コード例 #1
0
        public async Task GET()
        {
            Guid       testId           = Guid.Empty;
            PhraseEdit gottenPhraseEdit = null;

            var isAsyncComplete = false;
            var hasError        = false;

            EnqueueConditional(() => isAsyncComplete);
            await Setup();

            try
            {
                var allPhrases = await PhraseList.GetAllAsync();

                testId           = allPhrases.First().Id;
                gottenPhraseEdit = await PhraseEdit.GetPhraseEditAsync(testId);
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNotNull(gottenPhraseEdit),
                    () => Assert.AreEqual(testId, gottenPhraseEdit.Id)
                    );

                EnqueueTestComplete();
                Teardown();
                isAsyncComplete = true;
            }
        }
コード例 #2
0
        public async Task MAKE_PHRASE_WITH_REALLY_LONG_VARIED_TEXT()
        {
            #region var reallyLongText
            var reallyLongText = @"asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`asd;flkjghweqrey8iuweqpoiuqtw[eoizsdfslknjvzxcknvl;/,asdmf;lkasdfj asldkf a/sldkf jwoieuofvahsdkj;fa;weio:KJSLDJIOWEJLKSJDFLWIUQOWUQ}R|)(_)(*+_)(*&^%$#@!~~!@#$%^&*()_+|}{POIUYTREWQASDFGHJKL:			ZXCVBNM<>? "" wijwfekjsdkfj sdfj zxcvbnm,./';lljhgfdsqwertyuiop[]\=-0987654321`";
            #endregion

            PhraseEdit newPhraseEdit    = null;
            PhraseEdit savedPhraseEdit  = null;
            PhraseEdit gottenPhraseEdit = null;


            var isAsyncComplete = false;
            var hasError        = false;
            EnqueueConditional(() => isAsyncComplete);
            await Setup();

            try
            {
                //NEW
                newPhraseEdit = await PhraseEdit.NewPhraseEditAsync();

                //EDIT
                newPhraseEdit.Text     = reallyLongText;
                newPhraseEdit.UserId   = SeedData.Ton.GetTestValidUserDto().Id;
                newPhraseEdit.Username = SeedData.Ton.TestValidUsername;
                Assert.AreEqual(SeedData.Ton.EnglishId, newPhraseEdit.LanguageId);

                //SAVE
                savedPhraseEdit = await newPhraseEdit.SaveAsync();

                //GET (CONFIRM SAVE)
                gottenPhraseEdit = await PhraseEdit.GetPhraseEditAsync(savedPhraseEdit.Id);
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNotNull(newPhraseEdit),
                    () => Assert.IsNotNull(savedPhraseEdit),
                    () => Assert.IsNotNull(gottenPhraseEdit),
                    () => Assert.AreEqual(savedPhraseEdit.Id, gottenPhraseEdit.Id),
                    () => Assert.AreEqual(savedPhraseEdit.Text, gottenPhraseEdit.Text)
                    );
                EnqueueTestComplete();
                Teardown();
                isAsyncComplete = true;
            }
        }
コード例 #3
0
        public async Task NEW_EDIT_BEGINSAVE_GET()
        {
            PhraseEdit newPhraseEdit    = null;
            PhraseEdit savedPhraseEdit  = null;
            PhraseEdit gottenPhraseEdit = null;

            var isAsyncComplete = false;
            var hasError        = false;

            EnqueueConditional(() => isAsyncComplete);
            await Setup();

            try
            {
                //NEW
                newPhraseEdit = await PhraseEdit.NewPhraseEditAsync();

                //EDIT
                newPhraseEdit.Text     = "TestPhrase NEW_EDIT_BEGINSAVE_GET";
                newPhraseEdit.UserId   = SeedData.Ton.GetTestValidUserDto().Id;
                newPhraseEdit.Username = SeedData.Ton.TestValidUsername;

                //SAVE
                savedPhraseEdit = await newPhraseEdit.SaveAsync();

                //GET (CONFIRM SAVE)
                gottenPhraseEdit = await PhraseEdit.GetPhraseEditAsync(savedPhraseEdit.Id);
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNotNull(newPhraseEdit),
                    () => Assert.IsNotNull(savedPhraseEdit),
                    () => Assert.IsNotNull(gottenPhraseEdit),
                    () => Assert.AreEqual(savedPhraseEdit.Id, gottenPhraseEdit.Id),
                    () => Assert.AreEqual(savedPhraseEdit.Text, gottenPhraseEdit.Text)
                    );

                EnqueueTestComplete();
                Teardown();
                isAsyncComplete = true;
            }
        }
コード例 #4
0
        public async Task GET_ALL_PHRASES_THAT_CONTAIN_THE_LETTER_H_IN_ALL_LANGUAGES()
        {
            Guid       testId     = Guid.Empty;
            PhraseEdit testPhrase = null;

            //THE SEARCH TEXT WE ARE LOOKING FOR
            string textToLookFor = "h";

            //ASSUME TRUE
            bool allRetrievedPhrasesContainTheCorrectText = true;

            var isAsyncComplete = false;
            var hasError        = false;

            EnqueueConditional(() => isAsyncComplete);
            await Setup();

            try
            {
                var phrases = await PhraseList.GetAllContainingTextAsyncCaseInsensitive(textToLookFor);

                testId = phrases.First().Id;

                //CHECK TO SEE IF ALL THE PHRASES CONTAIN THE TEXT TO LOOK FOR, LIKE THEY ARE SUPPOSED TO
                for (int i = 0; i < phrases.Count; i++)
                {
                    var phrase = phrases[i];

                    //LOWERCASE THE TEXTS FOR THE CHECK, BECAUSE THE RESULTS ARE CASE-INSENSITIVE,
                    //BUT THE STRING.CONTAINS(TEXT) METHOD IS CASE-SENSITIVE
                    var lowercasePhraseText    = phrase.Text.ToLower();
                    var lowercaseTextToLookFor = textToLookFor.ToLower();

                    if (!lowercasePhraseText.Contains(lowercaseTextToLookFor))
                    {
                        //THIS SHOULDN'T HAPPEN
                        allRetrievedPhrasesContainTheCorrectText = false;
                    }
                }

                //JUST TO CHECK TO SEE THAT OUR RESULTS WERE AT LEAST ONE, AND THAT IT'S A VALID PHRASE
                testPhrase = await PhraseEdit.GetPhraseEditAsync(testId);
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsTrue(allRetrievedPhrasesContainTheCorrectText),
                    () => Assert.IsNotNull(testPhrase),
                    () => Assert.AreEqual(testId, testPhrase.Id)
                    );

                EnqueueTestComplete();
                Teardown();
                isAsyncComplete = true;
            }
        }
コード例 #5
0
        public async Task MAKE_PHRASE_WITH_REALLY_REALLY_LONG_NUMERICAL_TEXT()
        {
            var maxLength = 300000; //worked

            maxLength = 100000;     //worked
            maxLength = 30000;      //just for a big number, to lessen time to do test.
            var    i = 0;
            string reallyReallyLongText = "";

            while (reallyReallyLongText.Length < maxLength)
            {
                reallyReallyLongText += i.ToString();
                i++;
                if (i == maxLength) //shouldn't happen, but no big deal if it does. It's just a reallyraeallyreallyreally long text.
                {
                    break;
                }
            }
            if (reallyReallyLongText.Length > maxLength)
            {
                reallyReallyLongText = reallyReallyLongText.Substring(0, maxLength);
            }

            PhraseEdit newPhraseEdit    = null;
            PhraseEdit savedPhraseEdit  = null;
            PhraseEdit gottenPhraseEdit = null;

            var isAsyncComplete = false;
            var hasError        = false;

            EnqueueConditional(() => isAsyncComplete);
            await Setup();

            try
            {
                //NEW
                newPhraseEdit = await PhraseEdit.NewPhraseEditAsync();

                //EDIT
                newPhraseEdit.Text     = reallyReallyLongText;
                newPhraseEdit.UserId   = SeedData.Ton.GetTestValidUserDto().Id;
                newPhraseEdit.Username = SeedData.Ton.TestValidUsername;

                //SAVE
                savedPhraseEdit = await newPhraseEdit.SaveAsync();

                //GET (CONFIRM SAVE)
                gottenPhraseEdit = await PhraseEdit.GetPhraseEditAsync(savedPhraseEdit.Id);
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNotNull(newPhraseEdit),
                    () => Assert.IsNotNull(savedPhraseEdit),
                    () => Assert.IsNotNull(gottenPhraseEdit),
                    () => Assert.AreEqual(savedPhraseEdit.Id, gottenPhraseEdit.Id),
                    () => Assert.AreEqual(reallyReallyLongText.Length, gottenPhraseEdit.Text.Length),
                    () => Assert.AreEqual(savedPhraseEdit.Text, gottenPhraseEdit.Text)
                    );

                EnqueueTestComplete();
                Teardown();
                isAsyncComplete = true;
            }
        }
コード例 #6
0
        public async Task NEW_EDIT_BEGINSAVE_GET_DELETE_GET()
        {
            PhraseEdit newPhraseEdit     = null;
            PhraseEdit savedPhraseEdit   = null;
            PhraseEdit gottenPhraseEdit  = null;
            PhraseEdit deletedPhraseEdit = null;

            //INITIALIZE TO EMPTY Phrase EDIT, BECAUSE WE EXPECT THIS TO BE NULL LATER
            PhraseEdit deleteConfirmedPhraseEdit = new PhraseEdit();

            var isAsyncComplete = false;
            var hasError        = false;

            EnqueueConditional(() => isAsyncComplete);
            await Setup();

            try
            {
                //NEW
                newPhraseEdit = await PhraseEdit.NewPhraseEditAsync();

                //EDIT
                newPhraseEdit.Text     = "TestPhrase NEW_EDIT_BEGINSAVE_GET_DELETE_GET";
                newPhraseEdit.UserId   = SeedData.Ton.GetTestValidUserDto().Id;
                newPhraseEdit.Username = SeedData.Ton.TestValidUsername;

                //SAVE
                savedPhraseEdit = await newPhraseEdit.SaveAsync();

                //GET (CONFIRM SAVE)
                gottenPhraseEdit = await PhraseEdit.GetPhraseEditAsync(savedPhraseEdit.Id);

                //DELETE (MARKS DELETE.  SAVE INITIATES ACTUAL DELETE IN DB)
                gottenPhraseEdit.Delete();
                deletedPhraseEdit = await gottenPhraseEdit.SaveAsync();

                try
                {
                    deleteConfirmedPhraseEdit = await PhraseEdit.GetPhraseEditAsync(deletedPhraseEdit.Id);
                }
                catch (Csla.DataPortalException dpex)
                {
                    var debugExecutionLocation        = Csla.ApplicationContext.ExecutionLocation;
                    var debugLogicalExecutionLocation = Csla.ApplicationContext.LogicalExecutionLocation;
                    //WE EXPECT AN ID NOT FOUND EXCEPTION. IF SOMETHING ELSE, RETHROW IT.
                    if (!TestsHelper.IsIdNotFoundException(dpex))
                    {
                        throw dpex;
                    }
                }
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNotNull(newPhraseEdit),
                    () => Assert.IsNotNull(savedPhraseEdit),
                    () => Assert.IsNotNull(gottenPhraseEdit),
                    () => Assert.IsNotNull(deletedPhraseEdit),
                    () => Assert.AreEqual(Guid.Empty, deleteConfirmedPhraseEdit.Id),
                    () => Assert.AreEqual(Guid.Empty, deleteConfirmedPhraseEdit.LanguageId),
                    () => Assert.AreEqual(Guid.Empty, deleteConfirmedPhraseEdit.UserId),
                    () => Assert.AreEqual(string.Empty, deleteConfirmedPhraseEdit.Username)
                    );

                EnqueueTestComplete();
                Teardown();
                isAsyncComplete = true;
            }
        }
コード例 #7
0
        public async Task GET_ALL_SET_NEW_LANGUAGE_SAVE_GET_CONFIRMNEWLANGUAGE()
        {
            var        allPhrasesCount = -1;
            PhraseEdit testPhrase      = null;
            PhraseEdit savedPhrase     = null;
            PhraseEdit gottenPhrase    = null;

            PhraseList allPhrases        = null;
            PhraseList savedAllPhrases   = null;
            PhraseList confirmAllPhrases = null;

            var isAsyncComplete = false;
            var hasError        = false;

            EnqueueConditional(() => isAsyncComplete);
            await Setup();

            try
            {
                //LOAD--------------
                allPhrases = await PhraseList.GetAllAsync();

                allPhrasesCount = allPhrases.Count;

                testPhrase = (from phrase in allPhrases
                              where phrase.Language.Text == _ServerEnglishLang.Text
                              select phrase).First();

                //testPhrase is english

                //EDIT---------
                testPhrase.BeginEdit();
                testPhrase.Language = _ServerSpanishLang;
                testPhrase.ApplyEdit();

                //SAVE-------------
                savedAllPhrases = await allPhrases.SaveAsync();

                savedPhrase = (from phrase in savedAllPhrases
                               where phrase.Text == testPhrase.Text
                               select phrase).First();

                Assert.AreEqual(_ServerSpanishLang.Text, savedPhrase.Language.Text);
                Assert.AreEqual(_ServerSpanishLang.Id, savedPhrase.Language.Id);
                Assert.AreEqual(_ServerSpanishLang.Id, savedPhrase.LanguageId);

                //GET-----------
                gottenPhrase = await PhraseEdit.GetPhraseEditAsync(savedPhrase.Id);

                //CONFIRM----------
                //confirm language swap worked.
                Assert.AreEqual(_ServerSpanishLang.Text, gottenPhrase.Language.Text);
                Assert.AreEqual(_ServerSpanishLang.Id, gottenPhrase.Language.Id);
                Assert.AreEqual(_ServerSpanishLang.Id, gottenPhrase.LanguageId);
                //confirm we haven't glitched our data and magically doubled the size of our allPhrases.
                confirmAllPhrases = await PhraseList.GetAllAsync();

                Assert.AreEqual(allPhrasesCount, confirmAllPhrases.Count);
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNotNull(allPhrases),
                    () => Assert.IsNotNull(confirmAllPhrases),

                    //KEEP THIS LAST IN THE CALLBACKS
                    () => Teardown()
                    );

                EnqueueTestComplete();
                isAsyncComplete = true;
            }
        }