void Awake() { if (InformationLogger.infoLogger == null) { InformationLogger.infoLogger = this; } else { Destroy(this.gameObject); return; } DontDestroyOnLoad(this.gameObject); SceneManager.sceneLoaded += OnLevelFinishedLoading; versionText.text = "Version: " + patchID; if (seed == 0) { seed = Random.Range(1, 1000000000); } Random.InitState(seed); seedText.text = "Seed: " + seed; gameID = System.DateTime.Now.ToString(); }
public void TestThatConstructorInitializeInformationLogger() { using (var informationLogger = new InformationLogger(GetPathForformationLogger())) { Assert.That(informationLogger, Is.Not.Null); informationLogger.Dispose(); } }
public void TestThatDisposeCanBeCalledMoreThanOnce() { using (var informationLogger = new InformationLogger(GetPathForformationLogger())) { Assert.That(informationLogger, Is.Not.Null); informationLogger.Dispose(); informationLogger.Dispose(); } }
public void TestThatLogInformationThrowsArgumentNullExceptionIfInformationIsNull() { var fixture = new Fixture(); using (var informationLogger = new InformationLogger(GetPathForformationLogger())) { Assert.Throws <ArgumentNullException>(() => informationLogger.LogInformation(null)); Assert.Throws <ArgumentNullException>(() => informationLogger.LogInformation(null, fixture.CreateMany <object>(5).ToArray())); informationLogger.Dispose(); } }
public void TestThatLogWarningThrowsArgumentNullExceptionIfWarningIsEmpty() { var fixture = new Fixture(); using (var informationLogger = new InformationLogger(GetPathForformationLogger())) { Assert.Throws <ArgumentNullException>(() => informationLogger.LogWarning(string.Empty)); Assert.Throws <ArgumentNullException>(() => informationLogger.LogWarning(string.Empty, fixture.CreateMany <object>(5).ToArray())); informationLogger.Dispose(); } }
public void TestThatLogWarningWritesWarningToLog() { var fixture = new Fixture(); using (var informationLogger = new InformationLogger(GetPathForformationLogger())) { informationLogger.LogWarning(fixture.CreateAnonymous <string>()); informationLogger.LogWarning("{0} {1} {2}", fixture.CreateAnonymous <string>(), fixture.CreateAnonymous <int>(), fixture.CreateAnonymous <object>()); informationLogger.Dispose(); } Assert.That(GetNumberOfLogFiles(), Is.EqualTo(1)); }
/// <summary> /// Adding configuration to the container for Inversion of Control. /// </summary> /// <param name="container">Container for Inversion of Control.</param> public void AddConfiguration(IWindsorContainer container) { var logPath = ConfigurationManager.AppSettings["LogPath"]; if (string.IsNullOrEmpty(logPath)) { throw new DeliveryEngineSystemException(Resource.GetExceptionMessage(ExceptionMessage.ApplicationSettingMissing, "LogPath")); } var informationLogger = new InformationLogger(new DirectoryInfo(Environment.ExpandEnvironmentVariables(logPath))); container.Register(Component.For <IInformationLogger>().Instance(informationLogger).LifeStyle.Singleton); }
public void TestThatDisposeReleasesInternalResources() { using (var informationLogger = new InformationLogger(GetPathForformationLogger())) { Assert.That(informationLogger, Is.Not.Null); informationLogger.Dispose(); var field = informationLogger.GetType().GetField("_disposed", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic); Assert.That(field, Is.Not.Null); // ReSharper disable PossibleNullReferenceException Assert.That(field.GetValue(informationLogger), Is.True); // ReSharper restore PossibleNullReferenceException } }