Exemplo n.º 1
0
        public void Get_ValuesReturnNull_ReturnIsNull()
        {
            // Arrange
            var valuesMock = new Mock <IValuesRepository>();

            valuesMock
            .Setup(x => x.Get(It.IsAny <int>()))
            .Returns <Value>(null);

            int keyIdPairsResult;
            var keyIdPairsMock = new Mock <IKeyIdPairsRepository>();

            keyIdPairsMock
            .Setup(x => x.TryGet(It.IsAny <string>(), out keyIdPairsResult))
            .Returns(true);

            var personalBackend = new PersonalBackendModel(
                valuesMock.Object,
                keyIdPairsMock.Object);

            // Act
            var result = personalBackend.TestGetMethod <object>("key");

            // Assert
            Assert.IsNull(result);

            keyIdPairsMock.Verify(x =>
                                  x.TryGet(It.IsAny <string>(), out keyIdPairsResult),
                                  Times.Once());

            valuesMock.Verify(x =>
                              x.Get(It.IsAny <int>()),
                              Times.Once());
        }
Exemplo n.º 2
0
        public void Get_KeyIsLong_ReturnIsNull()
        {
            // Arrange
            var valuesMock      = new Mock <IValuesRepository>();
            var keyIdPairsMock  = new Mock <IKeyIdPairsRepository>();
            var personalBackend = new PersonalBackendModel(
                valuesMock.Object,
                keyIdPairsMock.Object);

            // Act
            var result = personalBackend.TestGetMethod <object>(new string('k', 200));

            // Assert
            Assert.IsNull(result);
        }