Pass() static public method

Throws a SuccessException with the message and arguments that are passed in. This allows a test to be cut short, with a result of success returned to NUnit.
static public Pass ( ) : void
return void
コード例 #1
0
    public IEnumerator TestAssetReferenceTMethod()
    {
        yield return(ValidateTestDependency());

        PreInstall();

        Container.BindAsync <GameObject>()
        .FromAssetReferenceT(addressablePrefabReference)
        .AsCached();
        PostInstall();

        AddressableInject <GameObject> asyncPrefab = Container.Resolve <AddressableInject <GameObject> >();

        int frameCounter = 0;

        while (!asyncPrefab.HasResult && !asyncPrefab.IsFaulted)
        {
            frameCounter++;
            if (frameCounter > 10000)
            {
                Assert.Fail();
            }
            yield return(null);
        }

        Addressables.Release(asyncPrefab.AssetReferenceHandle);
        Assert.Pass();
    }
コード例 #2
0
        //[ExpectedException(typeof(System.Reflection.TargetInvocationException))]
        public void PlayingCardWithInsufficientManaShouldFailTest()
        {
            IList <Card> hand = new List <Card>
            {
                new Card(4),
                new Card(4),
                new Card(4),
            };

            Player player = new Player("Test", null, new List <Card>(), hand, mana: 3);

            PrivateObject playerO = new PrivateObject(player);

            try
            {
                playerO.Invoke("PlayCard", new Card(4), new StartingPlayerChooser().ChooseBetween(testPlayer, testPlayer), ActionType.DAMAGE);
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("Insufficient Mana"))
                {
                    Assert.Pass();
                }
                else
                {
                    Assert.Fail("Wskazany błąd nie zawiera frazy 'Insufficient Mana'");
                }
            }
        }
コード例 #3
0
        public void Actual(DataTestCase testCase)
        {
            Data.InitMarketData(testCase.Vol,
                                testCase.Rate,
                                testCase.EvalDate);

            var            pricingCfg      = new PricingConfiguration(testCase.GreekTypes);
            var            pricer          = new Pricer();
            PricingResults expectedResults = null;
            var            actualResults   = pricer.Results(testCase.Option, pricingCfg);
            var            error           = string.Empty;

            try
            {
                using (StreamReader file = File.OpenText(@"C:\Users\AHMED\source\repos\ConsoleApp1\ResultPricing.text"))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    expectedResults = (PricingResults)serializer.Deserialize(file, typeof(PricingResults));
                }
            }
            catch (Exception e)
            {
                Assert.Fail(error = string.Format("Not Deserialize result: {0}", e.Message));
            }

            if (actualResults.CompareResult(expectedResults))
            {
                Assert.Pass("No regression detected");
            }
            else
            {
                // save ecart
                Assert.Fail("regression detected");
            }
        }
コード例 #4
0
        public void AddForm_Test()
        {
            try
            {
                List <QuestionDTO> q = new List <QuestionDTO>();
                List <AnswerDTO>   a = new List <AnswerDTO>();
                a.Add(new AnswerDTO {
                    Answer = "a", AnswerID = 20
                });

                q.Add(new QuestionDTO {
                    QuestionID = 1, Question = "why?", Answers = a
                });

                FormDetailDTO f = new FormDetailDTO()
                {
                    Id        = 4,
                    Username  = "******",
                    Deadline  = "3",
                    Category  = "category1",
                    Title     = "Title1",
                    State     = "open",
                    NrVotes   = 100,
                    Questions = q
                };

                _formLogic.AddForm(f);
            }
            catch (Exception)
            {
                Assert.Pass();
            }
            Assert.Fail();
        }
コード例 #5
0
        //Validate Deletion
        internal void ValidateDeleteCertification()
        {
            try
            {
                String expectedValue1 = ExcelLibHelper.ReadData(4, "Certificate");

                //get the table list
                IList <IWebElement> Tablerows = driver.FindElements(By.XPath("//form/div[5]/div/div[2]/div/table/tbody/tr"));

                for (int i = 1; i <= Tablerows.Count; i++)
                {
                    string actualvalue1 = driver.FindElement(By.XPath("//form/div[5]/div/div[2]/div/table/tbody[" + i + "]/tr/td[1]")).Text;

                    //check if expected value is equal to actual value
                    if (expectedValue1 != actualvalue1)
                    {
                        SaveScreenShotClass save = new SaveScreenShotClass();
                        string img = save.SaveScreenshot(driver, "CerficationsDeleted");
                        Assert.Pass();
                        Console.WriteLine("Certification deleted");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #6
0
ファイル: OrderServiceTests.cs プロジェクト: blfortier/TDD
        public void WhenAUserAttemptsToOrderAnItemWithAQuantityOfZeroThrowInvalidOrderException()
        {
            var shoppingCart = new ShoppingCart();

            shoppingCart.Items.Add(new ShoppingCartItem {
                ItemId = Guid.NewGuid(), Quantity = 0
            });
            var customerId      = Guid.NewGuid();
            var expectedOrderId = Guid.NewGuid();

            Mock.Arrange(() => _orderDataService.Save(Arg.IsAny <Order>()))
            .Returns(expectedOrderId)
            .OccursNever();
            // Act
            try
            {
                _orderService.PlaceOrder(customerId, shoppingCart);
            }
            catch
            {
                // Assert
                Mock.Assert(_orderDataService);
                Assert.Pass();
            }

            Assert.Fail();
        }
コード例 #7
0
ファイル: ApiClientTests.cs プロジェクト: RzuF/showTracker
        public void TestRealFullShow()
        {
            var show = new ShowService(new HttpClientWrapper()).GetFullShow(1);

            show.Wait();
            var showObj = _jsonSerializeService.DeserializeObject <FullShowDto>(show.Result);

            Assert.Pass();
        }
コード例 #8
0
        public void Create_User_Get_Same_User()
        {
            var userName = "******";
            var email    = "*****@*****.**";

            var userManager =
                (CustomUserManager <ApplicationUser>)_provider.GetRequiredService(
                    typeof(CustomUserManager <ApplicationUser>));

            var result = userManager.CreateAsync(new ApplicationUser(userName, email)).Result;

            if (!result.Succeeded)
            {
                Assert.Fail(result.Errors.ToString());
            }

            var userFromMail = userManager.FindByEmailAsync("*****@*****.**").Result;

            if (userFromMail == null)
            {
                Assert.Fail("User from mail has failed.");
            }

            if (userFromMail.UserName != userName || userFromMail.Email != email)
            {
                Assert.Fail("Username or email is corrupted.");
            }

            var userFromUsername = userManager.FindByNameAsync("Bob").Result;

            if (userFromUsername == null)
            {
                Assert.Fail("User from name has failed.");
            }

            if (userFromUsername.UserName != userName || userFromUsername.Email != email)
            {
                Assert.Fail("Username or email is corrupted.");
            }

            var userFromId = userManager.FindByIdAsync(userFromMail.Id).Result;

            if (userFromId.UserName != userName || userFromId.Email != email)
            {
                Assert.Fail("Username or email is corrupted.");
            }

            if (userFromId == null)
            {
                Assert.Fail("User from Id has failed.");
            }

            Assert.Pass();
        }
コード例 #9
0
 public void GetUserForms_Test2()
 {
     try
     {
         _formLogic.GetUserForms("user22", 0, 5, "open");
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #10
0
 public void GetContentForm_Test3()
 {
     try
     {
         _formLogic.GetContentForm(-3);
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #11
0
 public void GetVotedForms_Test4()
 {
     try
     {
         _formLogic.GetVotedForms("asdasd", 0, 1, "all");
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #12
0
 public void GetUsername_Test4()
 {
     try
     {
         _formLogic.GetUsername(-100);
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #13
0
 public void GetCategoryForms_Test3()
 {
     try
     {
         _formLogic.GetCategoryForms(1, "asdas", 0, 5, "all");
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #14
0
 public void GetQuestionID_Test3()
 {
     try
     {
         _formLogic.GetQuestionID("question11", -1);
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #15
0
 public void GetCategory_Test4()
 {
     try
     {
         _formLogic.GetCategory(100);
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #16
0
 public void GetAllForms_Test5()
 {
     try
     {
         _formLogic.GetAllForms("asd1", "Title", 0, 5, "all");
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #17
0
 public void GetDetailResultForm_Test4()
 {
     try
     {
         _formLogic.GetDetailResultForm(-10);
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #18
0
 public void GetForm_Test3()
 {
     try
     {
         int id = _formLogic.GetForm(100).FormID;
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #19
0
 public void GetQuestionID_Test2()
 {
     try
     {
         _formLogic.GetQuestionID("asdasd", 1);
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #20
0
 public void GetCategoryID_Test()
 {
     try
     {
         _formLogic.GetCategoryID("asdasd");
     }
     catch (Exception)
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
コード例 #21
0
        public void DeleteCategory_Test2()
        {
            try
            {
                _categoryLogic.DeleteCategory(5);
            }
            catch (Exception)
            {
                Assert.Pass();
            }

            Assert.Fail();
        }
コード例 #22
0
        public void DeleteUser_Test3()
        {
            try
            {
                _userLogic.DeleteUser(10);
            }
            catch (Exception)
            {
                Assert.Pass();
            }

            Assert.Fail();
        }
コード例 #23
0
        public void GetUserRole_Test3()
        {
            try
            {
                _userLogic.GetUserRole("user4");
            }
            catch (Exception)
            {
                Assert.Pass();
            }

            Assert.Fail();
        }
コード例 #24
0
        public void GetUser_Test2()
        {
            try
            {
                _userLogic.GetUser(-1);
            }
            catch (Exception)
            {
                Assert.Pass();
            }

            Assert.Fail();
        }
コード例 #25
0
        public void DeleteForm_Test2()
        {
            Assert.AreEqual(3, _formLogic.GetAllForms("1", "Title", 0, 5, "all").Count);
            try
            {
                _formLogic.DeleteForm(-1);
            }
            catch (Exception)
            {
                Assert.Pass();
            }

            Assert.AreEqual(3, _formLogic.GetAllForms("1", "Title", 0, 5, "all").Count);
        }
コード例 #26
0
        public async Task PrepareStringsAsyncTest()
        {
            var validFilePath = @".\TestFiles\valid.nc";
            var preparer      = new GCodePreparer();
            await preparer.OpenFileAsync(validFilePath, new Progress <float>());

            try
            {
                await preparer.PrepareStringsAsync();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            Assert.Pass();
        }
コード例 #27
0
    public IEnumerator TestAddressableAsyncLoad()
    {
        yield return(ValidateTestDependency());

        PreInstall();
        AsyncOperationHandle <GameObject> handle = default;

        Container.BindAsync <GameObject>().FromMethod(async() =>
        {
            try
            {
                var locationsHandle = Addressables.LoadResourceLocationsAsync("TestAddressablePrefab");
                await locationsHandle.Task;
                Assert.Greater(locationsHandle.Result.Count, 0, "Key required for test is not configured. Check Readme.txt in addressable test folder");

                IResourceLocation location = locationsHandle.Result[0];
                handle = Addressables.LoadAsset <GameObject>(location);
                await handle.Task;
                return(handle.Result);
            }
            catch (InvalidKeyException)
            {
            }
            return(null);
        }).AsCached();
        PostInstall();

        yield return(null);

        AsyncInject <GameObject> asycFoo = Container.Resolve <AsyncInject <GameObject> >();

        int frameCounter = 0;

        while (!asycFoo.HasResult && !asycFoo.IsFaulted)
        {
            frameCounter++;
            if (frameCounter > 10000)
            {
                Addressables.Release(handle);
                Assert.Fail();
            }
            yield return(null);
        }

        Addressables.Release(handle);
        Assert.Pass();
    }
コード例 #28
0
        public void ShouldPlayAsManyCardsAsPossibleForMaximumDamageTest()
        {
            IEnumerable <Card> cards = new[]
            {
                new Card(1),
                new Card(2),
                new Card(3),
            };
            Move move = strategy.NextMove(3, 30, cards);

            if (move.Card.Value == 1 || move.Card.Value == 2)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail("Strategy not attacking with card 1 or 2");
            }
        }
コード例 #29
0
        public void ShouldMaximizeDamageOutputInCurrentTurnTest()
        {
            IEnumerable <Card> cards = new[]
            {
                new Card(7),
                new Card(6),
                new Card(4),
                new Card(3),
                new Card(2),
            };
            Move move = strategy.NextMove(8, 30, cards);

            if (move.Card.Value == 2 || move.Card.Value == 6)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail("Strategy not attacking with card 2 or 6");
            }
        }
コード例 #30
0
        public void TestBuildEntityViewComponentWithWrongImplementors()
        {
            void CheckFunction()
            {
                _entityFactory.BuildEntity <TestDescriptorWrongEntityViewInterface>(new EGID(1, group1),
                                                                                    new[] { new TestIt(2) });
                _simpleSubmissionEntityViewScheduler.SubmitEntities();
            }

            try
            {
                CheckFunction();
            }
            catch
            {
                Assert.Pass();
                return;
            }

            Assert.Fail();
        }