GithubHelp home page GithubHelp logo

jozefizso / systemwrapper Goto Github PK

View Code? Open in Web Editor NEW
172.0 15.0 62.0 4.54 MB

.NET library for easier testing of system APIs.

License: Microsoft Public License

C# 99.70% Batchfile 0.05% PowerShell 0.24%
c-sharp integration-testing unit-testing

systemwrapper's Introduction

systemwrapper's People

Contributors

304notmodified avatar alexleen avatar andrewnewcomb avatar chrischu avatar cjbush avatar evangelink avatar gpomykala avatar jozefizso avatar neilmcguire avatar rhyous avatar seveves avatar vkreynin avatar yannbrulhart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

systemwrapper's Issues

ZipFileWrap.Open does not pass Encoding parameter

On this line, the Encoding parameter that is passed to ZipFileWrap.Open should be passed into ZipFile.Open
https://github.com/jozefizso/SystemWrapper/blob/develop/SystemWrapper/IO/Compression/ZipFileWrap.cs#L41

Zip files created with .NET 4.6.0 are not cross platform compatible, because they use backslashes instead of forward slashes. This is fixed in .NET 4.6.1. We stumbled on the bug in ZipFileWrap because we were using this Stack Overflow workaround to get cross platform zip files. Later, when we started using ZipFileWrap, this code stopped working. This was traced to the bug on the above line where the Encoding parameter is not passed to the underlying .NET class.

No wrapper for System.Configuration.Configuration

Unfortunately there is no wrapper for System.Configuration.Configuration (the return type of the Open*Configuration-methods in IConfigurationManager).

A wrapper like that would be very useful though!

Updated SmtpClientWrap

Hey,

I am one of the developers on the original CodePlex site. As the CodePlex site is pretty much dead, I was going to fork it on GitHub today and found you already have, which is awesome. ๐Ÿ‘

The reason this came up today is that I have a new and more complete ISmptClient and SmtpClientWrap that I was going add to the project. However, my implementation calls MailMessage directly.

I notice in this fork, interfaces and wrappers were added for these objects that SmtpClientWrap currently uses:

MailMessage = IMailMessage, MailMessageWrap
MailAddress = IMailAddress, MailAddressWrap
MailAddressCollection = IMailAddressCollection, IMailAddressFactoryWrap
MailAddressFactory = IMailAddressFactory, IMailAddressFactoryWrap

I hesitate to say that someone waisted their time because I am not 100% sure they did. However, MailMessage, MailAddress, MailAddressCollection are all little more than poco classes and as such, they would fall into the category of objects that Should not be wrapped.

In a unit test, a MailMessage, MailAddress, MailAddressCollection can be created and used no problem. The original project intent was to provide interfaces and wrapping things that cannot be created and used in Unit Tests otherwise. These objects can.

Is there something hidden in these objects that required them to be wrapped?
Or is there another use case that suggests they Should be wrapped?

If not, I will submit a pull request with my new SmtpClientWrap and remove the unnecessary wrapping of these poco classes.

Obviously someone added these interfaces and before I submit a pull request to remove them I would like to verify whether they are really needed or not.

UnitTest is failing because of system language

I just forked this repo and ran the unittests:
SystemWrapper.Tests.Reflection.AssemblyWrapTests.AssemblyInstance_AssemblyWrapCreatedWithDefaultConstructor_ThrowsException is failing.
It expects the Exception Message to be in english. Isn't that a bit specific?
My system language isn't english so these kind of tests are failing.
Maybe Assert.Throws<type> is enough?

IDateTime doesn't implement IComparable

I was using linq with DateTime objects, now converted to IDateTime, but ordering them didn't work due to IComparable not being implemented for IDateTime.

The original DateTime object inherits from these interfaces:

IComparable, IFormattable, IConvertible, ISerializable, IComparable,IEquatable

Is this something IDateTime is supposed to offer?

On-Board project to the .NET Foundation

We're getting ready to bring the project into the .NET Foundation, but before we
do we need to do the following:

Getting into the .NET Foundation

  • Make sure the project has a good name that is easy to remember and
    spell. Check that it doesn't conflict with another existing project
  • Make sure the people involved in the project want to join the .NET Foundation
  • Make sure the project has a clear understanding about how it accepts contributions and the process
    it follows when selecting new committers to the project.
  • Register an interest in joining the .NET Foundation
  • Work with the .NET Foundation to fill out an On-Boarding Questionaire
  • .NET Foundation sends out completed questionaire to .NET Foundation Advisory Council for comments
  • .NET Foundation Executive Director submits new project proposal to the .NET Foundation Board
  • Configure a CI build for the project and ensure build status badges are available from the README

Once accepted into the .NET Foundation

  • Sign the contribution / assignment agreement
  • Agree a date to move into the .NET Foundation
  • Prepare a guest blog post announcing the move on the .NET Foundation Blog
  • Read the code of conduct,
    link to it in your code and
    understand what to do if you are concerned about any behaviour or have
    concerns reported to you.
  • Tell the world we have joined!
  • Get CLA Automation enabled to ensure contributors can easily sign the
    Contribution License Agreement
  • Send a PR to add the Project into the .NET Foundation
    list
  • Ensure the repo contents are up to date with .NET Foundation guidance
  • Review the README guidance and update if necessary
  • If applicable update the LICENSE file to show Copyright has been assigned to the .NET Foundation
    and look to update any file headers.
  • If applicable, update any copyright statements in websites owned by the project to reflect
    assignment to the .NET Foundation
  • If applicable, update any websites associated with the project to include
    "Supported by the .NET Foundation" or
    similar link back to the .NET Foundation in the footer. If applicable, please
    include image links from our swag repo. (We think a link in the footer using the horizontal logo looks very nice.)
  • Sign up for Project Leader news
  • Configure any resources requested from the .NET Foundation (SSL Certs, Code Signing,
    Secret Management, Build Servers etc)

Delegating prefix subset "SystemWrapper.Core" on Nuget for a netstandard 2.0 version

Thanks for your SystemWrapper.Wrappers package, it is exactly what I needed to mock the file system in my unit tests. Except that my project is in .Net Core 3.1. So I ported your package to netstandard 2.0.

I would like to publish this package on Nuget under the package id "SystemWrapper.Core". However, I think you have the package ID prefix "SystemWrapper" reserved with Nuget. So I was not able to push my package.

Would you be willing please to delegate the prefix subset "SystemWrapper.Core" to me? That would allow me to push my package with an id that makes it clear it is a version of your work.

Doc source

Hi,

What source do you use for the comments? I'll write a few missing wraps and pull request, and want to keep the same standard.

AssemblyFileVersion not updated with new packages

I recently attempted to upgrade to use the latest nuget package. The file version of the dll's were never changed which causes issues for wix installers. They look at the file version to see if they should replace the dll on an upgrade.
So in this case the installer didn't replace the dll and now the app crashes on startup using the wrong dll.

I see that the AssemblyVersion has been updated with each release in AssemblySharedInfo.cs but not the AssemblyFileVersion.
I don't know if there is a reason to not increment the AssemblyFileVersion as well but It'd be appreciated if it was.

Question: Any plans for .NET 6?

.NET 6 is out since the end of last year. This is a long-term support (LTS) release that will be supported for three years. I do not know if there are any braking change concerning the IO etc.
As the unifying .NET 6 is supported only by the Visual Studio 2022 then multi-targeted platform would be a versatile solution.

Your thoughts on this?

Unity thinks the SystemWrapper.dll is broken

Do you (or someone else) have any experience with using SystemWrapper in a Unity project? When I add the SystemWrapper.dll and the SystemInterface.dll to the project, Unity complains that the former is broken:

Unloading broken assembly Assets/Plugins/SystemWrapper/SystemWrapper.dll, this assembly can cause crashes in the runtime.

Weirdly enough, I seem to be able to use it anyway. Unfortunately, I don't get any other error message to indicate what might be causing this.

SqlClient related factories not added to project

Following classes:

  • SqlCommandFactory
  • SqlConnectionFactory
  • SqlDataAdapterFactory
  • SqlDataAdapterWrap
  • SqlParameterCollectionWrap

Are implemented and added to source code but they are not added to SystemWrapper.csproj and thus they are no compiled.
Is this intentional or are they removed/not added by accident?

Assembly.GetExecutingAssembly() doesn't work correctly.

There are cases when Calling assembly also work incorrectly (depends on JIT) but I can't reproduce it regularly.
And looks like Release and Debug builds work differently but that's not related to SystemWrappers I don't think.
Code to reproduce with:

#r "$NuGet\SystemWrapper.Interfaces\0.24.0.177\lib\net45\SystemInterface.dll"
#r "$NuGet\SystemWrapper.Wrappers\0.24.0.177\lib\net45\SystemWrapper.dll"

using SystemInterface.Reflection;
using SystemWrapper.Reflection;

void ExecutingAssembly(IAssembly assembly)
{
    var sys = assembly.GetExecutingAssembly().FullName;
    var clr = Assembly.GetExecutingAssembly().FullName;
    $"{sys}{Environment.NewLine}{clr}".Dump("Executing");
}

void CallingAssembly(IAssembly assembly)
{
    var sys = assembly.GetCallingAssembly().FullName;
    var clr = Assembly.GetCallingAssembly().FullName;
    $"{sys}{Environment.NewLine}{clr}".Dump("Calling");
}

void EntryAssembly(IAssembly assembly)
{
    var sys = assembly.GetEntryAssembly().FullName;
    var clr = Assembly.GetEntryAssembly().FullName;
    $"{sys}{Environment.NewLine}{clr}".Dump("Entry");
}
IAssembly assembly = new AssemblyWrap();
ExecutingAssembly(assembly);
CallingAssembly(assembly);
EntryAssembly(assembly);

output:

Executing:
SystemWrapper, Version=0.24.0.177, Culture=neutral, PublicKeyToken=fbc3a63dd3cf8960
โ„›โ„˜-5deae9ff-10fc-4bfe-b099-b1621ae5f24b-6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

Calling:
โ„›โ„˜-5deae9ff-10fc-4bfe-b099-b1621ae5f24b-6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
โ„›โ„˜-5deae9ff-10fc-4bfe-b099-b1621ae5f24b-6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

Entry:
RoslynPad.Host32, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
RoslynPad.Host32, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

StreamWriterWrap doesn't invoke Dispose on StreamWriterInstance

StreamWriterWrap doesn't invoke Dispose on StreamWriterInstance. When using this like in the example Flush method of StreamWriterInstance is not invoke during Dispose because Dispose is invoked on base class of wrap (which is TextWriter) and Dispose on StreamWriterInstance is not invoked.

using (var writer = new StreamWriterWrap("filename, false)) { writer.Write("content"); }

So when using it as above the "content" will not be written into the file.

Having problems using MOQ

here's my code:

           var diMock = new Mock<IDirectoryInfo>();  
            diMock.Setup(i => i.Create());  
            try  
            {  
                var obj = diMock.Object;  
            }catch(Exception ex)  
            {  
                //SYSTEM.Runtime.Remoting.ObjRef exception here...  
            }

any ideas?

Update for .Net 6.0

I have just updated my app to .Net 6.0. How do I change SystemWrapper.Interfaces to be able to use it with .Net 6.0? Do I need to install a different package?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.