Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
        public void GetAllTimeframes_returnsProperCollection()
        {
            //Arrange
            Mock <ITimeframeService> mockService = new Mock <ITimeframeService>();
            var expectedTimeframes = getTimeframesCollection();

            mockService.Setup(s => s.GetAllTimeframes()).Returns(expectedTimeframes);
            Timeframe.injectService(mockService.Object);

            //Act.
            var timeframes = Timeframe.GetAllTimeframes();

            //Assert.
            bool areEquivalent = timeframes.HasTheSameItems(expectedTimeframes);

            Assert.IsTrue(areEquivalent);
        }