Exemple #1
0
 public void TestInitialize()
 {
     using (MyTrailsContext context = new MyTrailsContext())
     {
         context.ClearDatabase();
         context.SaveChanges();
     }
 }
        public void TestInitialize()
        {
            using (MyTrailsContext context = new MyTrailsContext())
            {
                context.ClearDatabase();
                context.SaveChanges();

                TripType tripType = context.TripTypes.First();
                this._anyTripTypeId = tripType.Id;
                this._anyTripTypeWtaId = tripType.WtaId;
            }

            this._anyTrail = new Trail
            {
                Name = "Any Trail Name",
                WtaId = "any-wta-id",
                Url = new Uri("http://any/trail/uri"),
            };

            this._wtaClientMock = new Mock<IWtaClient>(MockBehavior.Strict);
            this._wtaClientMock
                .Setup(wc => wc.FetchTripReports(It.IsAny<string>()))
                .Returns((string ti) => TaskExt.WrapInTask<IList<WtaTripReport>>(() => new List<WtaTripReport>
                {
                    new WtaTripReport
                    {
                        Title = "Any title",
                        Author = "Any author",
                        Date = DateTime.Now,
                        FullReportUrl = new Uri(new Uri("http://any.base.url"), AnyWtaTripReportId),
                        HikeType = this._anyTripTypeWtaId,
                        Photos = 
                        {
                            new Uri("http://any/domain/photoUrl.jpg"),
                        },
                    }
                }));
            this._wtaClientMock
                .Setup(wc => wc.BuildRetryPolicy(It.IsAny<ILog>()))
                .Returns(new RetryPolicy(new StubErrorDetectionStrategy(), retryCount: 0));

            this._extender = new TripReportExtender
            {
                WtaClient = this._wtaClientMock.Object,
                Logger = new StubLog(),
            };
        }
        /// <summary>
        /// Clear test data from the database.
        /// </summary>
        private void ClearDatabase()
        {
            using (MyTrailsContext trailContext = new MyTrailsContext())
            {
                trailContext.ClearDatabase();
                trailContext.Addresses.Truncate();

                trailContext.SaveChanges();
            }
        }