コード例 #1
0
        private void GreetBtn_Click(object sender, RoutedEventArgs e)
        {
            var service  = new GreetService();
            var name     = NameTxt.Text;
            var greeting = service.Greet(name);

            ResultTxt.Text = greeting;
        }
コード例 #2
0
        public void should_greet_with_correct_parameters()
        {
            var actualGreeting = greetService.Greet(TestName);

            const string expectedGreeting =
                "Hello, John!\nMy secret is - My Secret\nYour Personal info - Personal Info\nBye";

            Assert.That(actualGreeting, Is.EqualTo(expectedGreeting));
        }
コード例 #3
0
        public void Greet_NameAdded_ReturnGreetings()
        {
            // Arrange
            var service = new GreetService();
            // Act
            var greeting = service.Greet(".NET Padawan");

            // Assert
            Assert.AreEqual("Welcome .NET Padawan, my friend!", greeting);
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: MohammadAkbari/UnitTest
        public void GreetService_HaveGreatDay()
        {
            Shim shim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2019, 2, 20, 20, 50, 0));

            var greetService = new GreetService();

            var response = string.Empty;

            PoseContext.Isolate(() =>
            {
                response = greetService.Greet();
            }, shim);

            Assert.Equal("Have a great day!", response);
        }
コード例 #5
0
ファイル: UnitTest1.cs プロジェクト: MohammadAkbari/UnitTest
        public void GreetService_GoodMorning(string time)
        {
            var dateTime = Convert.ToDateTime(time);

            Shim shim = Shim.Replace(() => DateTime.Now).With(() => dateTime);

            var greetService = new GreetService();

            var response = string.Empty;

            PoseContext.Isolate(() =>
            {
                response = greetService.Greet();
            }, shim);

            Assert.Equal("Good morning!", response);
        }