Esempio n. 1
0
        public void ById_returnsExistingInstance()
        {
            //Arrange
            Mock <ITimeframeService> mockService = new Mock <ITimeframeService>();
            Timeframe expectedTimeframe          = new Timeframe(DEFAULT_ID, DEFAULT_NAME, DEFAULT_UNIT_TYPE, DEFAULT_UNITS_COUNTER);

            mockService.Setup(s => s.GetTimeframeById(DEFAULT_ID)).Returns(expectedTimeframe);
            Timeframe.injectService(mockService.Object);

            //Act.
            Timeframe timeframe = Timeframe.ById(DEFAULT_ID);

            //Assert.
            Assert.AreSame(expectedTimeframe, timeframe);
        }
Esempio n. 2
0
        public void ById_returnsNull_ifNotExistInRepository()
        {
            //Arrange
            Mock <ITimeframeService> mockService = new Mock <ITimeframeService>();
            Timeframe nullTimeframe = null;

            mockService.Setup(s => s.GetTimeframeById(DEFAULT_ID)).Returns(nullTimeframe);
            Timeframe.injectService(mockService.Object);

            //Act.
            Timeframe timeframe = Timeframe.ById(DEFAULT_ID);

            //Assert.
            Assert.IsNull(timeframe);
        }