コード例 #1
0
        public async Task TEST_DELETE_USER_THAT_DOESNT_EXIST()
        {
            string randomUsername = GenerateRandomUsername();

            Business.DeleteUserReadOnly deleter = null;

            var isAsyncComplete = false;
            var hasError        = false;

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

            try
            {
                deleter = await Business.DeleteUserReadOnly.CreateNewAsync(randomUsername);
            }
            catch (Csla.DataPortalException dpex)
            {
                //WE EXPECT AN EXCEPTION OF TYPE USER NOT FOUND. OTHERWISE,
                //WE NEED TO RETHROW THE EXCEPTION.
                if (!TestsHelper.IsUserNotFoundException(dpex))
                {
                    throw dpex;
                }
            }
            catch
            {
                //HAS ERROR REFERS TO THE METHOD HAS A PROBLEM.
                //IT DOES NOT MEAN THAT WE HAVE AN EXCEPTION, BECAUSE
                //WE ARE INDEED EXPECTING AN EXCEPTION.
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNull(deleter),
                    () => Teardown()
                    );

                EnqueueTestComplete();

                isAsyncComplete = true;
            }
        }
コード例 #2
0
        public async Task NEW_EDIT_BEGINSAVE_GET_DELETE_GET()
        {
            PhraseBeliefEdit newPhraseBeliefEdit     = null;
            PhraseBeliefEdit savedPhraseBeliefEdit   = null;
            PhraseBeliefEdit gottenPhraseBeliefEdit  = null;
            PhraseBeliefEdit deletedPhraseBeliefEdit = null;

            //INITIALIZE TO EMPTY PhraseBelief EDIT, BECAUSE WE EXPECT THIS TO BE NULL LATER
            PhraseBeliefEdit deleteConfirmedPhraseBeliefEdit = new PhraseBeliefEdit();

            var isAsyncComplete = false;
            var hasError        = false;

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

            try
            {
                //NEW
                newPhraseBeliefEdit = await PhraseBeliefEdit.NewPhraseBeliefEditAsync();

                //EDIT
                newPhraseBeliefEdit.TimeStamp = DateTime.Now - TimeSpan.FromDays(7);
                newPhraseBeliefEdit.Text      = "TestPhraseBelief.Text edited in NEW_EDIT_BEGINSAVE_GET_DELETE_GET test";
                newPhraseBeliefEdit.Strength  = 3.0d;
                newPhraseBeliefEdit.Phrase    = _TestPhraseEdit;
                Assert.AreEqual(SeedData.Ton.TestValidUsername, newPhraseBeliefEdit.Username);

                //SAVE
                savedPhraseBeliefEdit = await newPhraseBeliefEdit.SaveAsync();

                //GET (CONFIRM SAVE)
                gottenPhraseBeliefEdit =
                    await PhraseBeliefEdit.GetPhraseBeliefEditAsync(savedPhraseBeliefEdit.Id);

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

                try
                {
                    deleteConfirmedPhraseBeliefEdit
                        = await PhraseBeliefEdit.GetPhraseBeliefEditAsync(deletedPhraseBeliefEdit.Id);
                }
                catch (Csla.DataPortalException dpex)
                {
                    var debugExecutionLocation        = Csla.ApplicationContext.ExecutionLocation;
                    var debugLogicalExecutionLocation = Csla.ApplicationContext.LogicalExecutionLocation;
                    //WE EXPECT THE ID TO NOT BE FOUND, OTHERWISE RETHROW THE EXCEPTION
                    if (!TestsHelper.IsIdNotFoundException(dpex))
                    {
                        throw dpex;
                    }
                }
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNotNull(newPhraseBeliefEdit),
                    () => Assert.IsNotNull(savedPhraseBeliefEdit),
                    () => Assert.IsNotNull(gottenPhraseBeliefEdit),
                    () => Assert.IsNotNull(deletedPhraseBeliefEdit),
                    () => Assert.AreEqual(Guid.Empty, deleteConfirmedPhraseBeliefEdit.Id),
                    () => Assert.AreEqual(Guid.Empty, deleteConfirmedPhraseBeliefEdit.PhraseId)
                    );

                EnqueueTestComplete();
                Teardown();
                isAsyncComplete = true;
            }
        }
コード例 #3
0
        public async Task NEW_EDIT_BEGINSAVE_GET_DELETE_GET()
        {
            LineEdit newLineEdit     = null;
            LineEdit savedLineEdit   = null;
            LineEdit gottenLineEdit  = null;
            LineEdit deletedLineEdit = null;

            //INITIALIZE TO EMPTY Line EDIT, BECAUSE WE EXPECT THIS TO BE NULL LATER
            LineEdit confirmDeleteLineEdit = new LineEdit();

            var deleteIsConfirmed = false;

            var isAsyncComplete = false;
            var hasError        = false;

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

            try
            {
                //NEW
                newLineEdit = await LineEdit.NewLineEditAsync();

                //EDIT
                newLineEdit.Phrase.Text     = "TestLine.PhraseText NEW_EDIT_BEGINSAVE_GET";
                newLineEdit.Phrase.Language = _ServerEnglishLang;
                newLineEdit.LineNumber      = 0;
                Assert.AreEqual(SeedData.Ton.TestValidUsername, newLineEdit.Username);

                //SAVE
                savedLineEdit = await newLineEdit.SaveAsync();

                //GET (CONFIRM SAVE)
                gottenLineEdit = await LineEdit.GetLineEditAsync(savedLineEdit.Id);

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

                try
                {
                    confirmDeleteLineEdit = await LineEdit.GetLineEditAsync(deletedLineEdit.Id);

                    var debugExecutionLocation        = Csla.ApplicationContext.ExecutionLocation;
                    var debugLogicalExecutionLocation = Csla.ApplicationContext.LogicalExecutionLocation;
                }
                catch (Csla.DataPortalException dpex)
                {
                    if (TestsHelper.IsIdNotFoundException(dpex))
                    {
                        deleteIsConfirmed = true;
                    }
                }
            }
            catch
            {
                hasError = true;
            }
            finally
            {
                EnqueueCallback(
                    () => Assert.IsFalse(hasError),
                    () => Assert.IsNotNull(newLineEdit),
                    () => Assert.IsNotNull(savedLineEdit),
                    () => Assert.IsNotNull(gottenLineEdit),
                    () => Assert.IsNotNull(deletedLineEdit),
                    () => Assert.AreEqual(Guid.Empty, confirmDeleteLineEdit.Id),
                    () => Assert.AreEqual(Guid.Empty, confirmDeleteLineEdit.UserId),
                    () => Assert.IsNull(confirmDeleteLineEdit.Phrase),
                    () => Assert.IsNull(confirmDeleteLineEdit.User),
                    () => Assert.IsTrue(deleteIsConfirmed)
                    );

                EnqueueTestComplete();
                Teardown();
                isAsyncComplete = true;
            }
        }
コード例 #4
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;
            }
        }
コード例 #5
0
        public async Task NEW_EDIT_BEGINSAVE_GET_DELETE_GET()
        {
            #region Setup (try..)
            var isAsyncComplete = false;
            EnqueueConditional(() => isAsyncComplete);
            await Setup();

            try
            {
                #endregion
                LanguageEdit languageEdit        = null;
                LanguageEdit savedLanguageEdit   = null;
                LanguageEdit gottenLanguageEdit  = null;
                LanguageEdit deletedLanguageEdit = null;

                //INITIALIZE TO EMPTY LANGUAGE EDIT, BECAUSE WE EXPECT THIS TO BE NULL LATER
                LanguageEdit deleteConfirmedLanguageEdit = new LanguageEdit();

                //NEW
                languageEdit = await LanguageEdit.NewLanguageEditAsync();

                //EDIT
                languageEdit.Text = "TestLanguage";

                //SAVE
                savedLanguageEdit = await languageEdit.SaveAsync();

                //GET (CONFIRM SAVE)
                gottenLanguageEdit = await LanguageEdit.GetLanguageEditAsync(savedLanguageEdit.Id);

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

                EnqueueTestComplete();

                try
                {
                    deleteConfirmedLanguageEdit = await LanguageEdit.GetLanguageEditAsync(deletedLanguageEdit.Id);

                    throw new Exception();
                }
                catch (Csla.DataPortalException dpex)
                {
                    //WE ARE EXPECTING ONLY ID NOT FOUND EXCEPTIONS
                    if (!TestsHelper.IsIdNotFoundException(dpex))
                    {
                        throw dpex;
                    }

                    Assert.IsNotNull(languageEdit);
                    Assert.IsNotNull(savedLanguageEdit);
                    Assert.IsNotNull(gottenLanguageEdit);
                    Assert.IsNotNull(deletedLanguageEdit);
                    Assert.AreEqual(Guid.Empty, deleteConfirmedLanguageEdit.Id);
                    Assert.AreEqual(string.Empty, deleteConfirmedLanguageEdit.Text);
                    Assert.AreEqual(Guid.Empty, deleteConfirmedLanguageEdit.UserId);
                    Assert.AreEqual(string.Empty, deleteConfirmedLanguageEdit.Username);
                }
                #region (...finally) Teardown
            }
            finally
            {
                Teardown();
                isAsyncComplete = true;
            }
            #endregion
        }