public void SaveSiteConditions(SiteVisit visit)
        {
            if (visit == null)
            {
                throw new ArgumentNullException("visit");
            }

            SiteVisitMapper.Insert(visit);
            ConditionsMapper.Insert(visit.StartConditions);
            ConditionsMapper.Insert(visit.EndConditions);
        }
Exemple #2
0
        public void t_SiteVisit_Save_Insert()
        {
            SiteVisit toInsert = new SiteVisit()
            {
                Id            = TestHelper.TestGuid1,
                EndConditions = new SiteCondition()
                {
                    Id          = TestHelper.TestGuid1,
                    SiteVisitId = TestHelper.TestGuid1,
                    Sky         = 0,
                    Temperature = new Business.DataTypes.Temperature()
                    {
                        Units = "C", Value = 20
                    },
                    Wind = 2
                },
                EndTimeStamp        = DateTime.Now,
                IsDataEntryComplete = true,
                LocationId          = TestHelper.TestGuid4,
                ObserverId          = TestHelper.TestGuid3,
                RecorderId          = TestHelper.TestGuid2,
                StartConditions     = new SiteCondition()
                {
                    Id          = TestHelper.TestGuid2,
                    SiteVisitId = TestHelper.TestGuid1,
                    Sky         = 1,
                    Temperature = new Business.DataTypes.Temperature()
                    {
                        Units = "C", Value = 23
                    },
                    Wind = 2
                },
                StartTimeStamp = DateTime.Now.AddHours(-2),
                Comments       = "asdf asdfa sdf asdfasdfasdf"
            };

            SiteVisitMapper.Insert(toInsert);

            using (IbaUnitTestEntities iba = new IbaUnitTestEntities())
            {
                var SiteVisitQuery = from SiteVisits in iba.SiteVisit_ado1 select SiteVisits;
                Assert.IsNotNull(SiteVisitQuery, "Query result is null");
                Assert.AreEqual(1, SiteVisitQuery.Count(), "Wrong number of results in query");
                SiteVisit_ado adoSiteVisit = SiteVisitQuery.First();
                validateObjectEquality(toInsert, adoSiteVisit);
            }
        }