Ejemplo n.º 1
0
        void SetupPropertyNotSetWontWork()
        {
            var moq = new Mock <IPropertyType>();
            var sut = new APropertyUser(moq.Object, 0);

            sut.Add(10);

            Assert.Equal <int>(0, moq.Object.Counter);
        }
        void PropertyIsSet()
        {
            var moq = new Mock <IPropertyType>();
            var sut = new APropertyUser(moq.Object, 42);

            sut.Add(10);

            moq.VerifySet(x => x.Counter = 10, Times.Once);
        }
Ejemplo n.º 3
0
        void SetupPropertySetsToDefault()
        {
            var moq = new Mock <IPropertyType>();
            var sut = new APropertyUser(moq.Object, 0);

            moq.SetupProperty(x => x.Counter);

            sut.Add(10);

            Assert.Equal <int>(10, moq.Object.Counter);
        }
Ejemplo n.º 4
0
        void SetupPropertyWithInitialValue()
        {
            var moq = new Mock <IPropertyType>();
            var sut = new APropertyUser(moq.Object, 0);

            moq.SetupProperty(x => x.Counter, 42);

            sut.Add(10);

            Assert.Equal <int>(52, moq.Object.Counter);
        }
Ejemplo n.º 5
0
        void SetupPropertyAllProperties()
        {
            var moq = new Mock <IPropertyType>();
            var sut = new APropertyUser(moq.Object, 0);

            // Call this before any other moq.Setup(...)
            // To avoid overload of behaviour
            moq.SetupAllProperties();

            sut.Add(10);

            Assert.Equal <int>(10, moq.Object.Counter);
        }