public decimal Substract(decimal value)
        {
            StaticLogger.Write($"Substracting {value} from {Value}.");
            Value -= value;

            return(Value);
        }
        public decimal Add(decimal value)
        {
            StaticLogger.Write($"Adding {value} to {Value}.");
            Value += value;

            return(Value);
        }
Esempio n. 3
0
        public void IsLoginOK_WhenCalled_WritesToLog()
        {
            Isolate.Fake.StaticMethods(typeof(StaticLogger));
            var lm = new LoginManagerWithStatics();

            lm.IsLoginOK("a", "b");

            Isolate.Verify
            .WasCalledWithAnyArguments(() => StaticLogger.Write(""));
        }
Esempio n. 4
0
        public void IsLoginOK_StaticLoggerThrowsException_CallsStaticWebService()
        {
            Isolate.Fake.StaticMethods <StaticLogger>();
            Isolate.Fake.StaticMethods <StaticWebService>();
            Isolate
            .WhenCalled(() => StaticLogger.Write("anything"))
            .WillThrow(new LoggerException("fake exception"));


            var lm = new LoginManagerWithStatics();

            lm.IsLoginOK("a", "b");

            Isolate.Verify.WasCalledWithAnyArguments(() =>
                                                     StaticWebService.Write(""));
        }
Esempio n. 5
0
 public bool IsLoginOK(string user, string password)
 {
     try
     {
         StaticLogger.Write("blah");
     }
     catch (LoggerException e)
     {
         StaticWebService.Write(e.Message + Environment.MachineName);
     }
     if (m_users[user] != null &&
         (string)m_users[user] == password)
     {
         return(true);
     }
     return(false);
 }
 public bool IsLoginOK(string user, string password)
 {
     try
     {
         string text = "loginrequested";
         StaticLogger.Write(text);     // <--callLogger()
     }
     catch (LoggerException e)
     {
         string text = e.Message + Environment.MachineName;
         StaticWebService.Write(text);
     }
     if (m_users[user] != null &&
         (string)m_users[user] == password)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 7
0
        public void IsLoginOK_StaticLoggerThrowsException_CallsStaticWebServiceWithCorrectText()
        {
            string textWrittenToWebService = null;

            Isolate.Fake.StaticMethods <StaticLogger>();
            Isolate.Fake.StaticMethods <StaticWebService>();
            Isolate
            .WhenCalled(() => StaticLogger.Write(""))
            .WillThrow(new LoggerException("fake exception"));

            Isolate
            .WhenCalled(() => StaticWebService.Write(""))
            .DoInstead(context =>
                       textWrittenToWebService = (string)context.Parameters[0]);

            var lm = new LoginManagerWithStatics();

            lm.IsLoginOK("a", "b");


            StringAssert.Contains("fake exception", textWrittenToWebService);
        }
Esempio n. 8
0
 protected virtual void CallLogger(string text)
 {
     StaticLogger.Write(text);
 }
Esempio n. 9
0
 protected virtual void CallStaticWs()
 {
     StaticLogger.Write("blah");
 }
Esempio n. 10
0
 protected static void LoggerWrite(string user)
 {
     StaticLogger.Write(user);
 }
Esempio n. 11
0
 /// <summary>
 /// Encapsulates the call to the StaticLogger in a protected virtual method.
 /// A testable class can now be made (in the UnitTest project) which inherits
 /// from this Calculator class and overrides the WriteToStaticLogger method
 /// to break the dependency with the logger.
 /// </summary>
 /// <param name="message">Message to log.</param>
 protected virtual void WriteToStaticLogger(string message)
 {
     StaticLogger.Write(message);
 }
Esempio n. 12
0
 protected virtual void LogStaticMessage(string user)
 {
     StaticLogger.Write(string.Format("user {0} logged in ok", user));
 }
Esempio n. 13
0
 public v void WriteLogger(string user)
 {
     StaticLogger.Write(user);
 }