public void TideDataValue_Properties_Test() { foreach (CultureInfo culture in AllowableCulture) { ChangeCulture(culture); using (CSSPDBContext dbTestDB = new CSSPDBContext(DatabaseTypeEnum.SqlServerTestDB)) { TideDataValueService tideDataValueService = new TideDataValueService(new Query() { Lang = culture.TwoLetterISOLanguageName }, dbTestDB, ContactID); int count = 0; if (count == 1) { // just so we don't get a warning during compile [The variable 'count' is assigned but its value is never used] } count = tideDataValueService.GetTideDataValueList().Count(); TideDataValue tideDataValue = GetFilledRandomTideDataValue(""); // ------------------------------- // ------------------------------- // Properties testing // ------------------------------- // ------------------------------- // ----------------------------------- // [Key] // Is NOT Nullable // tideDataValue.TideDataValueID (Int32) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.TideDataValueID = 0; tideDataValueService.Update(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "TideDataValueID"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.TideDataValueID = 10000000; tideDataValueService.Update(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TideDataValue", "TideDataValueID", tideDataValue.TideDataValueID.ToString()), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = TideSite)] // tideDataValue.TideSiteTVItemID (Int32) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.TideSiteTVItemID = 0; tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "TideSiteTVItemID", tideDataValue.TideSiteTVItemID.ToString()), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.TideSiteTVItemID = 1; tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "TideSiteTVItemID", "TideSite"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // tideDataValue.DateTime_Local (DateTime) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.DateTime_Local = new DateTime(); tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "DateTime_Local"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.DateTime_Local = new DateTime(1979, 1, 1); tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "DateTime_Local", "1980"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // tideDataValue.Keep (Boolean) // ----------------------------------- // ----------------------------------- // Is NOT Nullable // [CSSPEnumType] // tideDataValue.TideDataType (TideDataTypeEnum) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.TideDataType = (TideDataTypeEnum)1000000; tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "TideDataType"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPEnumType] // tideDataValue.StorageDataType (StorageDataTypeEnum) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.StorageDataType = (StorageDataTypeEnum)1000000; tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "StorageDataType"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [Range(0, 10000)] // tideDataValue.Depth_m (Double) // ----------------------------------- //CSSPError: Type not implemented [Depth_m] //CSSPError: Type not implemented [Depth_m] tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.Depth_m = -1.0D; Assert.AreEqual(false, tideDataValueService.Add(tideDataValue)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Depth_m", "0", "10000"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, tideDataValueService.GetTideDataValueList().Count()); tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.Depth_m = 10001.0D; Assert.AreEqual(false, tideDataValueService.Add(tideDataValue)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "Depth_m", "0", "10000"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, tideDataValueService.GetTideDataValueList().Count()); // ----------------------------------- // Is NOT Nullable // [Range(0, 10)] // tideDataValue.UVelocity_m_s (Double) // ----------------------------------- //CSSPError: Type not implemented [UVelocity_m_s] //CSSPError: Type not implemented [UVelocity_m_s] tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.UVelocity_m_s = -1.0D; Assert.AreEqual(false, tideDataValueService.Add(tideDataValue)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "UVelocity_m_s", "0", "10"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, tideDataValueService.GetTideDataValueList().Count()); tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.UVelocity_m_s = 11.0D; Assert.AreEqual(false, tideDataValueService.Add(tideDataValue)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "UVelocity_m_s", "0", "10"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, tideDataValueService.GetTideDataValueList().Count()); // ----------------------------------- // Is NOT Nullable // [Range(0, 10)] // tideDataValue.VVelocity_m_s (Double) // ----------------------------------- //CSSPError: Type not implemented [VVelocity_m_s] //CSSPError: Type not implemented [VVelocity_m_s] tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.VVelocity_m_s = -1.0D; Assert.AreEqual(false, tideDataValueService.Add(tideDataValue)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "VVelocity_m_s", "0", "10"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, tideDataValueService.GetTideDataValueList().Count()); tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.VVelocity_m_s = 11.0D; Assert.AreEqual(false, tideDataValueService.Add(tideDataValue)); Assert.AreEqual(string.Format(CSSPServicesRes._ValueShouldBeBetween_And_, "VVelocity_m_s", "0", "10"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); Assert.AreEqual(count, tideDataValueService.GetTideDataValueList().Count()); // ----------------------------------- // Is Nullable // [CSSPEnumType] // tideDataValue.TideStart (TideTextEnum) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.TideStart = (TideTextEnum)1000000; tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "TideStart"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is Nullable // [CSSPEnumType] // tideDataValue.TideEnd (TideTextEnum) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.TideEnd = (TideTextEnum)1000000; tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "TideEnd"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPAfter(Year = 1980)] // tideDataValue.LastUpdateDate_UTC (DateTime) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.LastUpdateDate_UTC = new DateTime(); tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsRequired, "LastUpdateDate_UTC"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.LastUpdateDate_UTC = new DateTime(1979, 1, 1); tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateDate_UTC", "1980"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [CSSPExist(ExistTypeName = "TVItem", ExistPlurial = "s", ExistFieldID = "TVItemID", AllowableTVtypeList = Contact)] // tideDataValue.LastUpdateContactTVItemID (Int32) // ----------------------------------- tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.LastUpdateContactTVItemID = 0; tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes.CouldNotFind_With_Equal_, "TVItem", "LastUpdateContactTVItemID", tideDataValue.LastUpdateContactTVItemID.ToString()), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); tideDataValue = null; tideDataValue = GetFilledRandomTideDataValue(""); tideDataValue.LastUpdateContactTVItemID = 1; tideDataValueService.Add(tideDataValue); Assert.AreEqual(string.Format(CSSPServicesRes._IsNotOfType_, "LastUpdateContactTVItemID", "Contact"), tideDataValue.ValidationResults.FirstOrDefault().ErrorMessage); // ----------------------------------- // Is NOT Nullable // [NotMapped] // tideDataValue.HasErrors (Boolean) // ----------------------------------- // No testing requied // ----------------------------------- // Is NOT Nullable // [NotMapped] // tideDataValue.ValidationResults (IEnumerable`1) // ----------------------------------- // No testing requied } } }
public TideDataValueTest() { tideDataValue = new TideDataValue(); tideDataValueExtraA = new TideDataValueExtraA(); tideDataValueExtraB = new TideDataValueExtraB(); }