public void VerifyPropertyWithVerifyGet()
        {
            var mock     = new Mock <IPropertyManager>();
            var nameUser = new PropertyManagerConsumer(mock.Object);

            nameUser.GetName();

            mock.VerifyGet(m => m.FirstName, Times.Once);
        }
        public void VerifyPropertyIsSet_WithSpecificValue_WithVerifySet()
        {
            var mock     = new Mock <IPropertyManager>();
            var nameUser = new PropertyManagerConsumer(mock.Object);

            nameUser.ChangeName("No Shrubbery!");

            mock.VerifySet(m => m.FirstName = "No Shrubbery!");
        }
        public void ItIsAny()
        {
            var mock     = new Mock <IPropertyManager>();
            var nameUser = new PropertyManagerConsumer(mock.Object);

            nameUser.ChangeRemoteName("Hamid");

            mock.Verify(m => m.MutateFirstName(It.IsAny <string>()), Times.Once);
        }
        public void Verify()
        {
            var mock     = new Mock <IPropertyManager>();
            var nameUser = new PropertyManagerConsumer(mock.Object);

            nameUser.ChangeRemoteName("My dear old wig");

            //we are verifying that ChangeRemoteName sends the correct string to MutateFirstName
            mock.Verify(m => m.MutateFirstName(It.Is <string>(a => a == "My dear old wig")), Times.Once);
        }
        public void VerifyPropertyIsSet_WithSpecificValue_WithSetupSet()
        {
            var mock     = new Mock <IPropertyManager>();
            var nameUser = new PropertyManagerConsumer(mock.Object);

            mock.SetupSet(m => m.FirstName = "Knights Of Ni!").Verifiable();

            nameUser.ChangeName("Knights Of Ni!");

            mock.Verify();
        }
        public void StupPropertyWithSetupGet()
        {
            var mock     = new Mock <IPropertyManager>();
            var nameUser = new PropertyManagerConsumer(mock.Object);

            mock.SetupGet(m => m.FirstName).Returns("Shrubbery!");

            var name = nameUser.GetName();

            name.Should().Be("Shrubbery!");
        }
        public void InitializeTrackPropertyWithSetUpProperty()
        {
            var mock     = new Mock <IPropertyManager>();
            var nameUser = new PropertyManagerConsumer(mock.Object);

            mock.SetupProperty(m => m.FirstName, "Regina");

            //You can't change the property later with setupGet, but with setupProperty you can.
            //Comment the setup property code and uncomment this to see the difference.
            //mock.SetupGet(m => m.FirstName).Returns("Regina");

            mock.Object.FirstName.Should().Be("Regina");

            mock.Object.FirstName = "Floyd";
            mock.Object.FirstName.Should().Be("Floyd");
        }